import { createPromotion } from "@Api/productApi"
import {
  Badge,
  Button,
  Checkbox,
  DatePicker,
  Divider,
  Empty,
  Form,
  Icon,
  ImgDefault,
  Input,
  InputNumber,
  message,
  Modal,
  Pagination,
  Popover,
  Radio,
  Select,
  Space,
  Spin,
  Switch,
  Table,
  Tag,
  Tooltip
} from "@bytedance/mona-ui"
import type { ColumnProps } from "@bytedance/mona-ui/es/components/table"
import CircularJSON from "circular-json"
import moment from "moment"
import React, {
  forwardRef,
  useEffect,
  useImperativeHandle,
  useRef,
  useState
} from "react"

import { useAppSelector } from "~store"

import AddItemMt from "./addItemMt"
// import AddLtalpPritConfig from "./addLtalpPritConfig"
import {
  checkPromotionValidationFun,
  configFarMate,
  getProductListWork,
  getSkuListFunc,
  minskySeletcoption,
  pritConfigItem,
  pritFlotRadio,
  skuSetingoptions,
  skutypenameRadio,
  yureDateTime
} from "./ltalpFunc"

const { Option } = Select
const { Search } = Input
let chengeSopterkey = false
// const { RangePicker } = DatePicker;
function AddLtaLp(props, ref) {
  // const
  const activetConfiginfo = {
    activetTypeSelect: 0,
    selectTitlDater: 0,
    selectAcTime: 0,
    selectGetProdectListType: 0,
    selectGetTimeData: 30,
    selectNoteOrderTime: 5,
    isKuscuetser: 0,
    addActivetior: 0,
    addActivetiorBc: 0,
    setyufolyer: 0,
    yusretimeData: 15,
    endTimeSmit: 48,
    endTimeTmetr: 59,
    showAll: true,
    activtiTime: moment(),
    activetiQuantity: [moment(), moment().add(1, "days")],
    activetTimeBuy: [moment(), moment().add(1, "days")],
    activetName: "",
    errSkulen: 0,
    miniZekouter: 0.95,

    business_code: "LimitTime",
    begin_time: "", //开始时间
    end_time: "", //结束时间
    pre_begin_time: "", // 预热时间 在选择的时间后面加入
    order_expire_time: "",
    sold_out_type: "0",
    activetNameTitel: "",
    selectActPrdlist: [],
    selectConfigIndex: -1,
    sku_prd_config: {},
    pageSize: 10,
    page: 1,
    upConfug: {
      pritType: "0"
    },
    selectChengeShopItems: [], // 选中需要批量填充的数据
    globoSetConfig: {
      pritType: "0",
      pritort0: "",
      pritort1: "",
      pritort2: "",
      kuType: "0",
      ku0: "",
      ku1: "",
      xiangg: "",
      defaultExpandAllRows: false,
      defaultExpandedRowKeys: [],
      sherchIds: ""
    }
  }

  const [activetConfigInfoList, setActivetConfigInfoList] = useState([
    configFarMate(activetConfiginfo)
  ])
  const [addAllConfigData, setAddAllConfigData] = useState<any>([])
  const [showAddContent, setShowAddContent] = useState(false)
  const [hidenAll, setHidenAll] = useState(true)
  const [actOpenKeys, setactOpenKeys] = useState<any>([])
  const [addPritVstatus, setAddpritVstatus] = useState(false)
  const [editLtalpStatus, setEditLtalpStatus] = useState({
    status: false,
    index: -1
  })
  const [pritConfigList, setPritConfigList] = useState([pritConfigItem])

  // console.log('configDataUse', props.addConfigAllDatas)
  let [configDataUse, setConfigDataUse] = useState<any>([])
  if (
    configDataUse !== props.addConfigAllDatas &&
    props.addConfigAllDatas.length
  ) {
    // configDataUse = props.addConfigAllDatas
    setConfigDataUse(props.addConfigAllDatas)
  }
  useEffect(() => {
    if (
      addConfigActIndex !== -1 &&
      addAllConfigData[addConfigActIndex] &&
      addAllConfigData[addConfigActIndex].indexkey
    ) {
      getPrdListSkus(addAllConfigData[addConfigActIndex].indexkey)
    }
    // console.log('重新计算数据')
  }, [configDataUse])

  const [itSkuStatus, setEditSkuStatus] = useState({
    status: false,
    index: -1
  })
  const [getGoodsPredect, setGetGoodsPredect] = useState([])
  const [getSelectGoodsPredects, setGetSelectGoodsPredects] = useState<any>([])
  const [showselectActPrd, setShowselectActPrd] = useState(false)
  const [pageContent, setPageContent] = useState({
    page: 1,
    size: 10
  })
  const [shearProdectConfig, setShearProdectConfig] = useState({
    ids: ""
  })
  const [lodinRefoGoodsLodin, setlodinRefoGoodsLodin] = useState(true)
  if (!getGoodsPredect || !getGoodsPredect.length) {
    // 初始化获取商品列表
    getGoodsList()
  }
  function getGoodsList() {
    return new Promise((resolve, resject) => {
      getProductListWork([configFarMate(activetConfiginfo)]).then((res) => {
        // console.log("res0000+++-", res)
        setlodinRefoGoodsLodin(false)
        let copter = JSON.parse(JSON.stringify(res))
        if (copter && copter[0].ckproduct && copter[0].ckproduct.length) {
          // console.log("res[0].ckproductres[0].ckproduct", copter[0].ckproduct)
          copter[0].ckproduct.forEach((resquert) => {
            if (!resquert.chrackData) {
              resquert.chrackData = {
                check_pass: true
              }
            }
          })
        }
        setGetGoodsPredect(copter)
        // setLodinDataStatus(false)
        resolve(true)
      })
    })
  }
  const [selectActPrdItemKey, setSelectActPrdItemKey] = useState("")
  // const [selectActPrdItem, setSelectActPrdItem] = useState({})
  const [addActConfig, setAddActConfig] = useState(false)
  const [addConfigActIndex, setAddConfigActIndex] = useState(-1)
  const [lodinDataStatus, setLodinDataStatus] = useState(false)
  const [showErrContent, setshowErrContent] = useState(false)
  function copyToClipboard(text) {
    navigator.clipboard
      .writeText(text)
      .then(function () {
        message.success("复制成功")
      })
      .catch(function (err) {
        message.error("复制失败")
      })
  }
  useEffect(() => {
    const al = activetConfigInfoList.find((item) => {
      return item.showAll
    })
    if (!al) {
      setHidenAll(false)
    }
    const allcter = activetConfigInfoList.every((item) => {
      return !item.showAll
    })
    if (!allcter) {
      setHidenAll(true)
    }
  }, [activetConfigInfoList])
  interface ColumnPropsType {
    index: number
    name: string
  }
  function getActPrdDataList(isAc?) {
    if (!addAllConfigData || !addAllConfigData.length)
      return Modal.warning({
        title: "提示",
        content: "请先添加活动",
        okText: "添加活动",
        onOk: () => {
          setEditLtalpStatus({
            status: false,
            index: -1
          })
          setShowAddContent(true)
        }
      })
    setLodinDataStatus(true)
    getProductListWork(addAllConfigData).then((res) => {
      // console.log('res', res)
      setGetGoodsPredect(res)
      setLodinDataStatus(false)
      if (isAc) {
        // console.log('打开商品选择列表')
        getChackDataList(isAc, res)
      }
    })
  }
  function getChackDataList(item, getData?) {
    let addKeyItems = ""
    let keyItem = `${item.indexkey}${item.begin_time}${item.end_time}`
    const getDataData = getData || getGoodsPredect
    const getItemDter = getDataData.find((items: any) => {
      if (items.onkey === keyItem) {
        addKeyItems = keyItem
        setSelectActPrdItemKey(keyItem)
        return true
      }
      return false
    })
    // console.log('selectActPrdItemKey', addKeyItems)

    const copyActPrd = getItemDter
      ? JSON.parse(JSON.stringify(getItemDter.ckproduct))
      : []
    const gettabItem = addAllConfigData.find((itemsnerr) => {
      return (
        addKeyItems ===
        `${itemsnerr.indexkey}${itemsnerr.begin_time}${itemsnerr.end_time}`
      )
    })

    copyActPrd.forEach((cherSelect, index) => {
      if (!cherSelect.chrackData) {
        cherSelect.chrackData = {
          check_pass: true
        }
      }
      for (let i = 0; i < addAllConfigData.length; i++) {
        let selectKeys = `${addAllConfigData[i].indexkey}${addAllConfigData[i].begin_time}${addAllConfigData[i].end_time}`
        // if (selectKeys === addKeyItems) {
        //     return
        // }
        const quereSelect = addAllConfigData[i].selectActPrdlist.find(
          (isSelect) => {
            return isSelect.product_id === cherSelect.product_id
          }
        )
        // console.log('quereSelect', quereSelect)
        // 添加时段的判断
        if (quereSelect && selectKeys !== addKeyItems) {
          // console.log('已被选的商品的配置信息', addAllConfigData[i])
          // console.log('当前选中的活动配置信息', gettabItem)
          const startTime1 = new Date(addAllConfigData[i].begin_time)
          const endTime1 = new Date(addAllConfigData[i].end_time)

          // 第二个时间段
          const startTime2 = new Date(gettabItem.begin_time)
          const endTime2 = new Date(gettabItem.end_time)
          let isOverlap = !(endTime1 < startTime2 || startTime1 > endTime2)
          // 判断是否有交集
          // console.log('时间重叠', isOverlap)
          if (isOverlap) {
            cherSelect.selectStatus = false
            cherSelect.chrackData = {
              check_pass: false,
              reject_reason: `商品已经被活动${i + 1
                }选择且活动时间存在重叠，请移除后再选择`
            }

            cherSelect.selectActivet = quereSelect
            break
          }
        }
        cherSelect.selectStatus = false
        cherSelect.selectActivet = {}
      }
      if (gettabItem) {
        // 是同一个
        const isNowSelectItem = gettabItem.selectActPrdlist.find(
          (getSlectItem) => {
            return getSlectItem.product_id === cherSelect.product_id
          }
        )
        if (isNowSelectItem) {
          cherSelect.selectStatus = true
          cherSelect.selectActivet = gettabItem
          return
        }
        // 继续检查其他活动是否选择过
        cherSelect.selectStatus = false
        cherSelect.selectActivet = {}
        return
      }
    })
    setGetSelectGoodsPredects(copyActPrd)
    setShowselectActPrd(true)
  }
  const selectConfigTable: ColumnProps<ColumnPropsType>[] = [
    {
      title: "序号",
      key: "0",
      align: "center",
      width: 75,
      render: (text: any, record: any, index: number) => {
        return (
          <Badge count={record.errSkulen} align="outer">
            活动 {index + 1}
          </Badge>
        )
      }
    },
    {
      title: "活动类型",
      key: "1",
      align: "center",
      width: 150,
      render: (text: any, record: any, index: number) => {
        return <>{record.activetName}</> //{record.addActivetList.find(item => item.key === record.business_code)?.name}
      }
    },
    {
      title: "生效条件",
      key: "2",
      align: "center",
      width: 100,
      render: (text: any, record: any, index: number) => {
        return record.selectGetProdectListType ? "仅直播" : "活动期间"
      }
    },
    {
      title: "活动时间",
      key: "3",
      align: "center",
      width: 200,
      render: (text: any, record: any, index: number) => {
        if (!record.begin_time || !record.end_time) return null
        return (
          <Space direction="vertical" size={2}>
            <span>{record.begin_time}</span>
            <span>{record.end_time}</span>
          </Space>
        )
      }
    },
    {
      title: "持续时间",
      key: "15",
      align: "center",
      width: 100,
      render: (text: any, record: any, index: number) => {
        if (!record.begin_time || !record.end_time) return null

        const endater = moment.duration(
          moment(record.end_time).unix() - moment(record.begin_time).unix(),
          "seconds"
        )
        const d = endater.days()
        const h = endater.hours()
        const m = endater.minutes()
        const s = endater.seconds()

        return `${d ? d + "天" : ""}${h ? h + "小时" : ""}${m ? m + "分钟" : ""
          }${s ? s + "秒" : ""}`
      }
    },
    {
      title: "订单取消时间",
      key: "5",
      align: "center",
      render: (text: any, record: any, index: number) => {
        return record.selectNoteOrderTime + "分钟"
      }
    },
    {
      title: "库存售罄",
      key: "6",
      align: "center",
      render: (text: any, record: any, index: number) => {
        if (record.business_code === "OrdinaryTimeBuy") {
          return record.isKuscuetser
            ? record.addActivetior
              ? "停售，标示“已抢光”"
              : "恢复原价"
            : "不限库存"
        } else {
          return record.addActivetior ? "停售，标示“已抢光”" : "恢复原价"
        }
      }
    },
    {
      title: "预热",
      key: "7",
      align: "center",
      width: 80,
      render: (text: any, record: any, index: number) => {
        return record.business_code === "OrdinaryTimeBuy"
          ? "/"
          : record.setyufolyer
            ? `预热 ${yureDateTime.find((item) => item.value === record.yusretimeData)
              .title
            }`
            : "不预热"
      }
    },
    {
      title: "操作",
      key: "9",
      align: "center",
      width: 200,
      render: (text: any, record: any, index: number) => {
        return (
          <Space direction="vertical">
            <Space size={18}>
              <Badge
                count={record.selectActPrdlist.length}
                style={{
                  backgroundColor: record.selectActPrdlist.length
                    ? "#52c41a"
                    : "#F53B53"
                }}
                showZero
                overflowCount={2000}
                align="outer">
                <Button
                  type="link"
                  icon={<Icon type="AddIcon"></Icon>}
                  onClick={(e) => {
                    e.stopPropagation()
                    if (!getGoodsPredect || !getGoodsPredect.length) {
                      return Modal.warning({
                        title: "提示",
                        content: "请先获取商品列表",
                        okText: "获取商品",
                        onOk: () => {
                          getActPrdDataList(record)
                        }
                      })
                    }
                    setLodinDataStatus(true)
                    checkPromotionValidationFun(addAllConfigData).then(
                      (res) => {
                        setLodinDataStatus(false)
                        getChackDataList(record, res)
                        // getChackDataList(addAllConfigData[interAdd], res)
                      }
                    )
                  }}>
                  添加商品
                </Button>
              </Badge>
              <Badge
                status={record.selectConfigIndex === -1 ? "error" : "success"}
                align="outer">
                <Button
                  type="link"
                  icon={<Icon type="AddIcon"></Icon>}
                  onClick={(e) => {
                    e.stopPropagation()

                    if (
                      record.selectActPrdlist &&
                      record.selectActPrdlist.length
                    ) {
                      Modal.warning({
                        title: "提示",
                        content: "新增配置后将以配置项填写数据！！！",
                        onOk: () => {
                          setAddConfigActIndex(index)
                          setAddActConfig(true)
                        }
                      })
                      // if (!getGoodsPredect || !getGoodsPredect.length) {
                      //     return Modal.warning({
                      //         title: '提示',
                      //         content: '请先获取商品列表',
                      //         okText: '获取商品',
                      //         onOk: () => {
                      //             getActPrdDataList(record)
                      //         }
                      //     })
                      // }
                      // getChackDataList(record)

                      return
                    }
                    setAddConfigActIndex(index)
                    setAddActConfig(true)
                  }}>
                  添加配置
                </Button>
              </Badge>
            </Space>
            <Space>
              <Button
                type="link"
                icon={<Icon type="EditIcon"></Icon>}
                onClick={(e) => {
                  e.stopPropagation()

                  if (record.selectActPrdlist.length > 0) {
                    Modal.warning({
                      title: "提示",
                      content: `该活动已添加 ${record.selectActPrdlist.length} 个商品， 重新编辑将会清空已选的商品`,
                      onOk: () => {
                        record.selectActPrdlist = []
                        setAddAllConfigData([...addAllConfigData])
                        setEditLtalpStatus({
                          status: true,
                          index
                        })
                        activetConfigInfoList[0] = record
                        setActivetConfigInfoList([...activetConfigInfoList])
                        setShowAddContent(true)
                      }
                    })
                    return
                  }
                  e.stopPropagation()
                  setEditLtalpStatus({
                    status: true,
                    index
                  })
                  activetConfigInfoList[0] = record
                  setActivetConfigInfoList([...activetConfigInfoList])
                  setShowAddContent(true)
                }}>
                编辑
              </Button>

              <Button
                type="link"
                style={{ color: "#F11717" }}
                icon={<Icon type="DeleteIcon"></Icon>}
                onClick={(e) => {
                  e.stopPropagation()
                  if (record.selectActPrdlist.length > 0) {
                    return Modal.warning({
                      title: "提示",
                      content: `该活动已添加 ${record.selectActPrdlist.length} 个商品， 是否删除`,
                      onOk: () => {
                        record.selectActPrdlist = []
                        addAllConfigData.splice(index, 1)
                        setAddAllConfigData([...addAllConfigData])
                      }
                    })
                  }
                  record.selectActPrdlist = []
                  addAllConfigData.splice(index, 1)
                  setAddAllConfigData([...addAllConfigData])
                  // onDeleteImageItem && onDeleteImageItem()
                }}>
                删除
              </Button>
            </Space>
          </Space>
        )
      }
    }
  ]

  const selectLtaLpPrittable: ColumnProps<ColumnPropsType>[] = [
    {
      title: "序号",
      key: "0",
      align: "center",
      width: 110,
      render: (text: any, record: any, index: number) => {
        return (
          <Checkbox
            checked={
              index === addAllConfigData[addConfigActIndex].selectConfigIndex
            }
            onChange={(e) => {
              // console.log('e', e)
              // if(e.target.checked) {

              // }
              // console.log(' configDataUse[index]',  configDataUse[index])
              // addAllConfigData[addConfigActIndex].upConfug.pritType = configDataUse[index].pritType

              addAllConfigData[addConfigActIndex].selectConfigIndex = index
              setAddAllConfigData([...addAllConfigData])
            }}>
            配置{index + 1}
          </Checkbox>
        )
      }
    },
    {
      title: "类型",
      key: "1",
      align: "center",
      width: 69,
      dataIndex: "typeName"
    },
    {
      title: "sku价格，库存限制购",
      key: "2",
      align: "left",
      width: 310,
      render: (text: any, record: any, index: number) => {
        const itlenKey = `type${record.pritType}AllConfig`

        return (
          <>
            {record[itlenKey].map((item, index) => {
              return (
                <div key={index}>
                  <Space direction="vertical">
                    <Space>
                      <span>{item.skymin} 元</span>
                      <span>&lt;=SKU价格&lt;</span>
                      <span>{item.skymax} 元</span>
                    </Space>
                    <Space>
                      <span>
                        {record.typeName}:{item.prit}
                        {record.pritType === "0" || record.pritType === "1"
                          ? "元"
                          : "折"}
                      </span>
                      <span>限领{item.lin}个</span>
                      <span>
                        {item.kucuntype == "0"
                          ? "不限制库存"
                          : item.kucuntype == "1"
                            ? `库存(全部)`
                            : item.kucuntype == "2"
                              ? `库存(${item.bai}%)`
                              : `库存(${item.len}个)`}
                      </span>
                    </Space>
                  </Space>
                  {index !== record[itlenKey].length - 1 && (
                    <Divider
                      style={{
                        margin: "5px 0"
                      }}></Divider>
                  )}
                </div>
              )
            })}
          </>
        )
      }
    },
    // {
    //     title: '最低sku',
    //     key: '3',
    //     align: "left",
    //     width: 220,
    //     render: (text: any, record: any, index: number) => {
    //         const itlenMinConfKey = `type${record.pritType}MinConfigStatus`
    //         const itlenMinKey = `type${record.pritType}MinConfig`
    //         if (!record[itlenMinConfKey]) return '/'
    //         const item: any = record[itlenMinKey]
    //         return <Space direction="vertical">
    //             <Space>
    //                 <span>{record.typeName}:{item.prit}{(record.pritType === '0' || record.pritType === '1') ? '元' : '折'}</span>
    //                 <span>限领{item.lin}个</span>
    //                 <span>{item.kucuntype == "0" ? '不限制库存' : item.kucuntype == "1" ? `库存(全部)` : item.kucuntype == "2" ? `库存(${item.bai}%)` : `库存(${item.len}个)`}</span>
    //             </Space>
    //             <Space size={2}>
    //                 同低SKU:{minskySeletcoption.find((items) => {
    //                     return items.value === item.minskust
    //                 })?.label}
    //             </Space>
    //         </Space>
    //     }
    // }, {
    //     title: 'sku设置',
    //     key: '4',
    //     align: "center",
    //     width: 131,
    //     render: (text: any, record: any, index: number) => {
    //         const titlecontent = skuSetingoptions.find((item) => {
    //             return item.value === record.skuSeting

    //         })
    //         return titlecontent ? titlecontent.label : '/'
    //     }
    // },
    {
      title: "适配最低优惠",
      key: "4",
      align: "center",
      width: 131,
      render: (text: any, record: any, index: number) => {
        if (record.aotoPrtMin) return "自动"
        return "不适配"
      }
    },
    {
      title: "小数位数",
      key: "5",
      align: "center",
      render: (text: any, record: any, index: number) => {
        const getTer = record.pritFlot

        return getTer === "0"
          ? "保留两位小数"
          : getTer === "1"
            ? "保留一位小数"
            : getTer === "2"
              ? "保留整数"
              : `手动输入: ${record.flotNum}`
      }
    }
    // , {
    //     title: '操作',
    //     key: '5',
    //     align: "center",
    //     render: (text: any, record: any, index: number) => {
    //         return (<Space>
    //             <Space>
    //                 <Button type="link" icon={<Icon type='EditIcon'></Icon>} onClick={() => {
    //                     setEditSkuStatus({
    //                         status: true,
    //                         index
    //                     })
    //                     setAddpritVstatus(true)
    //                 }}>编辑</Button>
    //             </Space>
    //             <Space>
    //                 {/* <Button type="link" disabled={editLtalpStatus.status} style={{ color: '#F11717' }} icon={<Icon type="DeleteIcon"></Icon>} onClick={() => {
    //                     onDeleteImageItem && onDeleteImageItem()
    //                 }}>删除</Button> */}
    //                 <Button type="link" style={{ color: '#F11717' }} icon={<Icon type="DeleteIcon"></Icon>} onClick={() => {
    //                     pritConfigList.splice(index, 1)
    //                     setPritConfigList([...pritConfigList])
    //                 }}>删除</Button>
    //             </Space>
    //         </Space>)
    //     }
    // }
  ]

  function getListItems() {
    return getSelectGoodsPredects
      .filter((setnoter) => {
        if (showGoodsTypeStatus && !setnoter.chrackData.check_pass) return false
        return true
      })
      .filter((itemsdf) => {
        if (!shearProdectConfig.ids) return true
        const selectItem = shearProdectConfig.ids.split(/[\s,， ?]/)
        if (selectItem.length === 0) return true
        return selectItem.some((item) => {
          return item.includes(itemsdf.product_id)
        })
      })
      .filter((it, ins) => {
        const inStatus = (pageContent.page - 1) * pageContent.size
        const endStatus = inStatus + pageContent.size
        return ins >= inStatus && ins < endStatus
      })
  }

  const isBuyStatus = useAppSelector(
    (state) => state.jinritemaiProduct.isBuyStatus
  )
  const [errKeysleng, setErrkeysleng] = useState(0)
  useEffect(() => {
    // console.log('配置变化', addAllConfigData)
    // 检查错误的项
    // let errKeyleng = 0
    let errKeyCh = 0
    let allconme = 0
    addAllConfigData.forEach((res) => {
      errKeyCh = 0
      res.selectActPrdlist.forEach((redoe) => {
        redoe.children.forEach((errconter) => {
          // let kters = errconter.
          if (errconter.nock) {
            errKeyCh = errKeyCh + 1
          }
          if (errconter.kuerr) {
            errKeyCh = errKeyCh + 1
          }
          // console.log('检查错误项目', errconter)
        })
        // console.log('errKeyCh', errKeyCh)
      })
      allconme = errKeyCh + allconme
      res.errSkulen = errKeyCh

      // if (errKeyCh) {
      //     errKeyleng++
      // }
    })
    if (allconme !== errKeysleng) {
      setErrkeysleng(allconme)
      setAddAllConfigData([...addAllConfigData])
    }
  }, [addAllConfigData])
  const someMethod = async () => {
    // upContenProtiuer()
    if (isBuyStatus.status) {
      Modal.confirm({
        title: isBuyStatus.title,
        content: isBuyStatus.content,
        icon: null,
        okText: isBuyStatus.okText,
        cancelText: " 取消",
        onOk: () => {
          open(isBuyStatus.url)
          return
        }
      })
      return
    }
    // 判断是否创建活动
    if (!addAllConfigData || addAllConfigData.length === 0) {
      Modal.warning({
        title: "提示",
        content: "请先添加活动",
        // icon: null,
        okText: "添加活动",
        cancelText: " 取消",
        onOk: () => {
          setShowAddContent(true)
          return
        }
      })
      return
    }
    // 判断活动是否添加商品
    let addAllConfigDataStatus = true
    let interAdd
    for (let i = 0; i < addAllConfigData.length; i++) {
      console.log("addAllConfigData", addAllConfigData[i])
      if (
        !addAllConfigData[i].selectActPrdlist ||
        addAllConfigData[i].selectActPrdlist.length === 0
      ) {
        addAllConfigDataStatus = false
        interAdd = i
        break
      }
    }
    // console.log('addAllConfigDataStatus', addAllConfigDataStatus, addAllConfigData)
    if (!addAllConfigDataStatus) {
      Modal.warning({
        title: "提示",
        content: `请先添加第${interAdd + 1}个活动的商品`,
        // icon: null,
        okText: "添加活动商品",
        cancelText: " 取消",
        onOk: () => {
          if (!getGoodsPredect || !getGoodsPredect.length) {
            Modal.warning({
              title: "提示",
              content: "请先获取商品列表",
              okText: "获取商品",
              onOk: () => {
                getActPrdDataList(addAllConfigData[interAdd])
              }
            })
            return
          }
          setLodinDataStatus(true)
          checkPromotionValidationFun(addAllConfigData).then((res) => {
            setLodinDataStatus(false)
            getChackDataList(addAllConfigData[interAdd], res)
          })
          return
        }
      })
      return
    }

    // 判断是否添加配置
    // if (!configDataUse || !configDataUse.length) {
    //     Modal.warning({
    //         title: '提示',
    //         content: '添加活动后需设置活动sku价格配置',
    //         // icon: null,
    //         okText: '添加配置',
    //         cancelText: " 取消",
    //         onOk: () => {
    //             setEditSkuStatus({
    //                 status: false,
    //                 index: -1
    //             })
    //             setAddpritVstatus(true)
    //             return
    //         }
    //     })
    //     return
    // }
    let addAllConfigDataProd = true
    let addConteiNdes
    let noDataInfos = true
    let noDataContenr
    for (let i = 0; i < addAllConfigData.length; i++) {
      // console.log('addAllConfigData', addAllConfigData[i])
      if (addAllConfigData[i].selectConfigIndex == -1) {
        addAllConfigDataProd = false
        addConteiNdes = i
        break
      }
      if (!configDataUse[addAllConfigData[i].selectConfigIndex]) {
        noDataInfos = false
        noDataContenr = i
        break
      }
    }
    // if (!addAllConfigDataProd) {
    //     Modal.warning({
    //         title: '提示',
    //         content: `活动 ${addConteiNdes + 1} 请添加sku价格配置`,
    //         // icon: null,
    //         okText: '添加配置',
    //         cancelText: " 取消",
    //         onOk: () => {
    //             // setEditSkuStatus({
    //             //     status: false,
    //             //     index: -1
    //             // })
    //             // setAddpritVstatus(true)
    //             setAddConfigActIndex(addConteiNdes)
    //             setAddActConfig(true)
    //             return
    //         }
    //     })
    //     return
    // }
    // if (!noDataInfos) {
    //     Modal.warning({
    //         title: '提示',
    //         content: `活动 ${noDataContenr + 1} 的sku价格配置不存在请重新选择`,
    //         // icon: null,
    //         okText: '添加配置',
    //         cancelText: " 取消",
    //         onOk: () => {
    //             // setEditSkuStatus({
    //             //     status: false,
    //             //     index: -1
    //             // })
    //             // setAddpritVstatus(true)
    //             setAddConfigActIndex(noDataContenr)
    //             setAddActConfig(true)
    //             return
    //         }
    //     })
    //     return
    // }

    // console.log('提交创建,  获取sku列表')
    // 清洗需要获取sku的商品列表
    upContenProtiuer()
  }
  // 修改配置 选择商品时需要调用
  function getPrdListSkus(indexkey?) {
    if (!addAllConfigData || !addAllConfigData.length) return
    setLodinDataStatus(true)
    let setAddData = addAllConfigData
    if (indexkey) {
      setAddData = addAllConfigData.filter((ityr) => {
        return ityr.indexkey == indexkey
      })
    }
    const getAllContent = setAddData.map((res) => {
      let product_sku_infos: any = []
      return new Promise((resolve, reject) => {
        const prdids = res.selectActPrdlist.map((ids) => {
          return { product_id: ids.product_id }
        })
        const copyPrdIds = JSON.parse(JSON.stringify(prdids))
        while (copyPrdIds.length > 0) {
          product_sku_infos.push(copyPrdIds.splice(0, 100))
        }
        const getPrdSkuPromise = product_sku_infos.map((conters) => {
          const getItemData = {
            channel_products: conters,
            limit_stock_type: 0,
            activity_tool_type: 26,
            business_code: res.business_code,
            start_time: new Date(res.begin_time).getTime() / 1000,
            end_time: new Date(res.end_time).getTime() / 1000
          }
          return getSkuListFunc(getItemData)
        })
        Promise.all(getPrdSkuPromise).then((asler) => {
          const allContentList: any = []
          asler.forEach((resasdee) => {
            resasdee.data.forEach((skuitem) => {
              allContentList.push(skuitem)
            })
          })
          // 匹配配置项
          // res.sku_prd_config = configDataUse[res.selectConfigIndex]
          res.globoSetConfig.defaultExpandedRowKeys = []
          res.selectActPrdlist.forEach((contit) => {
            if (res.globoSetConfig.defaultExpandAllRows) {
              res.globoSetConfig.defaultExpandedRowKeys.push(contit.product_id)
            }
            // contit.allconfig = {
            //     allPlterNum: '',
            //     allPlteprt: '',
            //     allErrstatus: false,
            //     allErrText: '',

            //     pritNUmber: '', //降价后的价格范围

            //     kuErr: false,
            //     kuErrText: '',
            //     kuTiyrt: '',
            //     kuNum: '',

            //     linNum: 1,
            //     linTiyrt: ''
            // }

            const getSku = allContentList.filter((res) => {
              return res.product_id == contit.product_id
            })
            // contit.sku_list = getSku[0].sku_list
            contit.children = getSku[0].sku_list.map((resdder) => {
              resdder.nowprit = "" // 价格
              resdder.user_limit = 1 // 领取
              resdder.camp_stock_num = "" // 库存
              resdder.nock = false // 价格错误
              resdder.altext = "" // 价格错误提示
              resdder.miniprit = "" // 最小金额
              resdder.kuerr = false // 库存错误
              resdder.kuText = "" // 库存错误提示
              return resdder
            })
          })
          resolve(asler)
        })
      })
    })
    Promise.all(getAllContent).then((res) => {
      setLodinDataStatus(false)

      // console.log('res sku列表', res)
      // console.log('res sku列表666', addAllConfigData)
      fomaterData(indexkey, true)
      // 设置上sku列表
      // setAddAllConfigData([...addAllConfigData])
    })
  }
  useImperativeHandle(ref, () => ({
    someMethod,
    getPrdListSkus,
    setAddActConfig
  }))
  function countDecimalPlaces(num) {
    const decimalPart = String(num).split(".")[1]
    return decimalPart ? decimalPart.length : 0
  }

  function fomaterData(mher?, okyer?) {
    const miniStokList: any = []
    // console.log('获取sku')
    addAllConfigData.forEach((element, index) => {
      let getPritConfigAllData =
        element.sku_prd_config[
        `type${element.sku_prd_config.pritType}AllConfig`
        ]
      // const getPritConfigMinData = element.sku_prd_config[`type${element.sku_prd_config.pritType}MinConfig`]
      // const getPritConfigMinStatus = element.sku_prd_config[`type${element.sku_prd_config.pritType}MinConfigStatus`]
      if (mher && mher != element.indexkey) return
      if (mher && !okyer) {
        getPritConfigAllData =
          pritConfigItem[`type${element.upConfug.pritType}AllConfig`]
        console.log("pritConfigItem", pritConfigItem, element)
        if (
          element.business_code === "OrdinaryTimeBuy" &&
          element.upConfug.pritType == "2"
        ) {
          // getPritConfigAllData.prit = '9.9'
          getPritConfigAllData.forEach((pueyr) => {
            pueyr.prit = "9.9"
          })
        }
        console.log("getPritConfigAllData", getPritConfigAllData)
        element.sku_prd_config = pritConfigItem
      }
      const errskuContent: any = {
        num: index + 1,
        data: []
      }
      const filterMinOneStokList = element.selectActPrdlist.filter(
        (mintoek) => {
          if (element.business_code === "OrdinaryTimeBuy") return true
          const miter = mintoek.children
            .map((restrr) => restrr.origin_stock)
            .sort((a, b) => a - b)[0]
          // console.log('miter', miter)
          if (miter <= 0) {
            errskuContent.data.push(mintoek)
            return false
          }
          return true
        }
      )
      if (errskuContent.data && errskuContent.data.length) {
        miniStokList.push(errskuContent)
      }
      // console.log('sku库存不合格', miniStokList)
      element.selectActPrdlist = filterMinOneStokList
      if (!getPritConfigAllData) {
        // console.log('没有配置项目 需要手动填写默认一口价')
        element.selectActPrdlist.forEach((item) => {
          let skupriminandmax: any = []
          let kucun: any = []
          let lincunter: any = []
          let outerNumprt: any = []

          item.children.forEach((skuck) => {
            skuck.nowprit = ""
            skuck.user_limit = 1
            let moyers =
              skuck.origin_price - skuck.origin_price * element.miniZekouter
            skuck.miniprit =
              moyers > 100
                ? ~~(skuck.origin_price * element.miniZekouter) / 100
                : ~~(skuck.origin_price - 100) / 100
            skuck.camp_stock_num = ""
            skupriminandmax.push(skuck.nowprit)
            kucun.push(skuck.camp_stock_num)
            lincunter.push(skuck.user_limit)
          })
          let getMiAx = skupriminandmax.sort((a, b) => a - b)
          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
          let mi = getMiAx[0]
          let max = getMiAx[getMiAx.length - 1]
          if (mi == max) {
            item.allconfig.allPlterNum = mi
            item.allconfig.allPlteprt = "请输入"
          } else {
            item.allconfig.allPlterNum = ""
            item.allconfig.allPlteprt = `${mi}~${max}`
          }

          let kucunMiMx = kucun.sort((a, b) => a - b)
          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
          let kmi = kucunMiMx[0]
          let kmax = kucunMiMx[kucunMiMx.length - 1]
          if (kmi == kmax) {
            item.allconfig.kuNum = kmi
            item.allconfig.kuTiyrt = "请输入"
          } else {
            item.allconfig.kuNum = ""
            item.allconfig.kuTiyrt = `${kmi}~${kmax}`
          }

          let lincunterMiMx = lincunter.sort((a, b) => a - b)
          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
          let lmi = lincunterMiMx[0]
          let lmax = lincunterMiMx[lincunterMiMx.length - 1]
          if (lmi == lmax) {
            item.allconfig.linNum = lmi
            item.allconfig.linTiyrt = "请输入"
          } else {
            item.allconfig.linNum = ""
            item.allconfig.linTiyrt = `${lmi}~${lmax}`
          }
        })
        return
      }

      element.selectActPrdlist.forEach((item) => {
        // console.log('item', item)
        item.allconfig.kuErr = false
        let skupriminandmax: any = []
        let kucun: any = []
        let lincunter: any = []
        let outerNumprt: any = []

        item.children.forEach((skuck) => {
          // console.log('skuck', skuck)
          switch (element.upConfug.pritType) {
            case "0":
              // console.log('判断为一口价, 配置项目', getPritConfigAllData)
              // 一口价的判断
              getPritConfigAllData.forEach((router) => {
                // console.log('router', router)
                const minp = router.skymin * 100
                const maxp = router.skymax * 100
                if (skuck.origin_price >= minp && skuck.origin_price < maxp) {
                  const prit = fomaterPrice(
                    router.prit,
                    skuck.origin_price,
                    element.sku_prd_config,
                    skuck,
                    element
                  )
                  // console.log('prit条件赋值', prit, ~~(skuck.origin_price * 0.95) / 100)
                  if (!(mher && !skuck.nock && skuck.nowprit)) {
                    skuck.nowprit = prit / 100
                  }
                  skuck.user_limit = skuck.user_limit || router.lin
                  let moyer =
                    skuck.origin_price -
                    skuck.origin_price * element.miniZekouter
                  skuck.miniprit =
                    moyer > 100
                      ? ~~(skuck.origin_price * element.miniZekouter) / 100
                      : ~~(skuck.origin_price - 100) / 100
                  if (!(mher && !skuck.kuerr && skuck.camp_stock_num)) {
                    skuck.camp_stock_num = (() => {
                      // 库存
                      let maxKucun = 999999999999
                      if (element.business_code === "OrdinaryTimeBuy") {
                        return "0"
                      }
                      if (element.business_code === "LimitQuantity") {
                        maxKucun = 1000
                      }
                      if (router.kucuntype == "1") {
                        // 全部
                        return skuck.origin_stock > maxKucun
                          ? maxKucun
                          : skuck.origin_stock + ""
                      }
                      if (router.kucuntype == "2") {
                        // 百分比
                        return skuck.origin_stock * (router.bai / 100) >
                          maxKucun
                          ? maxKucun
                          : (skuck.origin_stock * (router.bai / 100)).toFixed(0)
                      }
                      if (router.kucuntype == "3") {
                        // 固定值
                        let monter =
                          router.len > skuck.origin_stock
                            ? router.len
                            : skuck.origin_stock
                        return monter > maxKucun ? maxKucun : monter
                      }
                    })()
                  }

                  skupriminandmax.push(skuck.nowprit)
                  kucun.push(skuck.camp_stock_num)
                  lincunter.push(skuck.user_limit)

                  // 检查是否开启了自动适配
                  // 限时限量活动才需要下面的步骤
                  if (prit > skuck.last_15_day_low_price) {
                    console.log("skuck", skuck)
                    skuck.nock = true
                    skuck.altext = `需小与等于该SKU近15天最低价 ${Number(
                      (skuck.last_15_day_low_price / 100).toFixed(2)
                    )}`
                    item.allconfig.allErrstatus = true
                    item.allconfig.allErrText =
                      "部分SKU一口价填写错误，请展开查看"
                    return
                  }
                  skuck.nock = false
                  item.allconfig.allErrstatus = false
                }
              })
              break
            case "1":
              getPritConfigAllData.forEach((router) => {
                // console.log('router', router)
                const minp = router.skymin * 100
                const maxp = router.skymax * 100
                if (skuck.origin_price >= minp && skuck.origin_price < maxp) {
                  const prit = fomaterPrice(
                    skuck.origin_price / 100 - router.prit,
                    skuck.origin_price,
                    element.sku_prd_config,
                    skuck,
                    element
                  )
                  // 前两种95折
                  // 最后一种99折

                  // console.log('prit条件赋值', prit, ~~(skuck.origin_price * 0.95) / 100)
                  console.log("直降后的金额", prit)
                  // if (mher && !skuck.nock && skuck.zhijiangprt && skuck.user_limit && skuck.camp_stock_num) return
                  if (
                    !(mher && !skuck.nock && skuck.nowprit && skuck.zhijiangprt)
                  ) {
                    skuck.nowprit = prit / 100
                    skuck.zhijiangprt = (
                      skuck.origin_price / 100 -
                      skuck.nowprit
                    ).toFixed(2)
                  }

                  skuck.user_limit = router.lin
                  let moyers =
                    skuck.origin_price -
                    skuck.origin_price * element.miniZekouter
                  skuck.miniprit =
                    moyers > 100
                      ? ~~(skuck.origin_price * element.miniZekouter) / 100
                      : ~~(skuck.origin_price - 100) / 100
                  if (!(mher && !skuck.kuerr && skuck.camp_stock_num)) {
                    skuck.camp_stock_num = (() => {
                      // 库存
                      let maxKucun = 999999999999
                      if (element.business_code === "OrdinaryTimeBuy") {
                        return "0"
                      }
                      if (element.business_code === "LimitQuantity") {
                        maxKucun = 1000
                      }
                      if (router.kucuntype == "1") {
                        // 全部
                        return skuck.origin_stock > maxKucun
                          ? maxKucun
                          : skuck.origin_stock + ""
                      }
                      if (router.kucuntype == "2") {
                        // 百分比
                        return skuck.origin_stock * (router.bai / 100) >
                          maxKucun
                          ? maxKucun
                          : (skuck.origin_stock * (router.bai / 100)).toFixed(0)
                      }
                      if (router.kucuntype == "3") {
                        // 固定值
                        let monter =
                          router.len > skuck.origin_stock
                            ? router.len
                            : skuck.origin_stock
                        return monter > maxKucun ? maxKucun : monter
                      }
                    })()
                  }

                  outerNumprt.push(skuck.nowprit)
                  skupriminandmax.push(skuck.zhijiangprt)
                  kucun.push(skuck.camp_stock_num)
                  lincunter.push(skuck.user_limit)

                  // 检查是否开启了自动适配
                  // 限时限量活动才需要下面的步骤
                  if (prit < 0.01) {
                    console.log("最低价格错误")
                    skuck.nock = true
                    skuck.altext = `${(
                      (skuck.origin_price * (1 - element.miniZekouter)) /
                      100
                    ).toFixed(2)}≤直降金额<${(skuck.origin_price / 100).toFixed(
                      2
                    )}（优惠力度至少${element.miniZekouter * 100
                      }折且优惠金额≥${((skuck.origin_price * 0.05) / 100).toFixed(
                        2
                      )}）可精确到小数点后两位`
                    item.allconfig.allErrstatus = true
                    item.allconfig.allErrText =
                      "部分SKU直降填写错误，请展开查看"
                    return
                  }
                  if (prit > skuck.last_15_day_low_price) {
                    console.log("skuck", skuck)
                    skuck.nock = true
                    skuck.altext = `需小与等于该SKU近15天最低价 ${Number(
                      (skuck.last_15_day_low_price / 100).toFixed(2)
                    )}`
                    item.allconfig.allErrstatus = true
                    item.allconfig.allErrText =
                      "部分SKU直降填写错误，请展开查看"
                    return
                  }
                  skuck.nock = false
                  item.allconfig.allErrstatus = false
                }
              })

              break
            case "2":
              getPritConfigAllData.forEach((router) => {
                // console.log('router', router)
                const minp = router.skymin * 100
                const maxp = router.skymax * 100
                if (skuck.origin_price >= minp && skuck.origin_price < maxp) {
                  let price = (skuck.origin_price / 100) * (router.prit / 10)
                  // 前两种95折
                  // 最后一种99折
                  // console.log('自动适配',element.sku_prd_config)
                  // console.log('prit条件赋值', prit, ~~(skuck.origin_price * 0.95) / 100)
                  // if (mher && !skuck.nock && skuck.zhijiangprt && skuck.user_limit && skuck.camp_stock_num) return

                  if (element.sku_prd_config.aotoPrtMin) {
                    // 自动适配折扣
                    const setPrit = price * 100
                    let minPrd = skuck.origin_price * element.miniZekouter
                    if (skuck.origin_price - minPrd < 100) {
                      minPrd = skuck.origin_price - 100
                    }
                    const prmPrits = skuck.origin_price - setPrit

                    let rtPri = 0

                    if (minPrd >= setPrit && prmPrits >= 100) {
                      rtPri = Math.ceil(setPrit)
                    } else {
                      rtPri = Math.ceil(minPrd)
                    }
                    // console.log('rtPri', skuck.last_15_day_low_price, rtPri)
                    if (
                      skuck.last_15_day_low_price &&
                      rtPri > skuck.last_15_day_low_price
                    ) {
                      // return skuck.last_15_day_low_price
                      skuck.zhijiangprt = (
                        ~~(
                          (skuck.last_15_day_low_price / skuck.origin_price) *
                          100
                        ) / 10
                      ).toFixed(1)
                      // console.log(' skuck.zhijiangprt', skuck.zhijiangprt, skuck.last_15_day_low_price)
                      // console.log(' skuck.zhijiangprt', skuck.zhijiangprt, skuck.last_15_day_low_price, skuck.origin_price)
                      skuck.nowprit = (
                        Math.ceil(
                          ~~(
                            (skuck.zhijiangprt / 10) *
                            (skuck.origin_price / 100) *
                            1000
                          ) / 10
                        ) / 100
                      ).toFixed(2)
                      outerNumprt.push(skuck.nowprit)
                    } else {
                      let zekouter: any = (
                        (rtPri / skuck.origin_price) *
                        10
                      ).toFixed(1)

                      let minterConter: any = (
                        Math.ceil(
                          ~~(
                            (zekouter / 10) *
                            (skuck.origin_price / 100) *
                            1000
                          ) / 10
                        ) / 100
                      ).toFixed(2)

                      if (skuck.origin_price / 100 - minterConter >= 1) {
                        skuck.zhijiangprt = zekouter
                        skuck.nowprit = minterConter
                      } else {
                        skuck.zhijiangprt =
                          ~~(
                            ((skuck.origin_price - 100) / skuck.origin_price) *
                            100
                          ) / 10
                        skuck.nowprit = (
                          Math.ceil(
                            ~~(
                              (skuck.zhijiangprt / 10) *
                              (skuck.origin_price / 100) *
                              1000
                            ) / 10
                          ) / 100
                        ).toFixed(2)
                      }

                      outerNumprt.push(skuck.nowprit)
                    }
                  } else {
                    const prit = fomaterPrice(
                      price,
                      skuck.origin_price,
                      element.sku_prd_config,
                      skuck,
                      element
                    )
                    if (
                      !(
                        mher &&
                        !skuck.nock &&
                        skuck.nowprit &&
                        skuck.zhijiangprt
                      )
                    ) {
                      skuck.zhijiangprt = router.prit
                      skuck.nowprit = prit / 100
                    }

                    outerNumprt.push(skuck.nowprit)
                  }
                  // console.log('打折后的金额', prit)

                  skuck.user_limit = router.lin
                  let moyers =
                    skuck.origin_price -
                    skuck.origin_price * element.miniZekouter
                  skuck.miniprit =
                    moyers > 100
                      ? Math.ceil(
                        ~~(skuck.origin_price * element.miniZekouter * 1000) /
                        100
                      ) / 100
                      : Math.ceil((~~(skuck.origin_price - 100) * 1000) / 10) /
                      100
                  skuck.camp_stock_num = (() => {
                    // 库存
                    let maxKucun = 999999999999
                    if (element.business_code === "OrdinaryTimeBuy") {
                      return "0"
                    }
                    if (element.business_code === "LimitQuantity") {
                      maxKucun = 1000
                    }
                    if (router.kucuntype == "1") {
                      // 全部
                      return skuck.origin_stock > maxKucun
                        ? maxKucun
                        : skuck.origin_stock + ""
                    }
                    if (router.kucuntype == "2") {
                      // 百分比
                      return skuck.origin_stock * (router.bai / 100) > maxKucun
                        ? maxKucun
                        : (skuck.origin_stock * (router.bai / 100)).toFixed(0)
                    }
                    if (router.kucuntype == "3") {
                      // 固定值
                      let monter =
                        router.len > skuck.origin_stock
                          ? router.len
                          : skuck.origin_stock
                      return monter > maxKucun ? maxKucun : monter
                    }
                  })()

                  skupriminandmax.push(skuck.zhijiangprt)
                  kucun.push(skuck.camp_stock_num)
                  lincunter.push(skuck.user_limit)

                  // 检查是否开启了自动适配
                  // 限时限量活动才需要下面的步骤
                  if (
                    skuck.zhijiangprt > element.miniZekouter * 10 ||
                    skuck.zhijiangprt < 1 ||
                    skuck.origin_price / 100 - skuck.nowprit < 1
                  ) {
                    // console.log('最低价格错误')
                    skuck.nock = true
                    skuck.altext = `打折范围：1.0~${element.miniZekouter * 10
                      }折（优惠力度至少${element.miniZekouter * 100
                      }折且优惠金额≥1）可精确到小数点后一位`
                    item.allconfig.allErrstatus = true
                    item.allconfig.allErrText =
                      "部分SKU一口价填写错误，请展开查看"
                    return
                  }
                  // console.log('skuck.nowprit', skuck.nowprit)
                  if (~~(skuck.nowprit * 100) > skuck.last_15_day_low_price) {
                    // console.log('skuck', skuck)
                    skuck.nock = true
                    skuck.altext = `需小与等于该SKU近15天最低价 ${Number(
                      (skuck.last_15_day_low_price / 100).toFixed(2)
                    )}`
                    item.allconfig.allErrstatus = true
                    item.allconfig.allErrText =
                      "部分SKU折扣填写错误，请展开查看"
                    return
                  }
                  skuck.nock = false
                  item.allconfig.allErrstatus = false
                }
              })

              break
            default:
              break
          }
          skuck.kuerr = false

          if (skuck.nock) {
            item.allconfig.allErrstatus = true
          }
        })
        if (outerNumprt && outerNumprt.length) {
          let getMiAxder = outerNumprt.sort((a, b) => a - b)
          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
          let mi = getMiAxder[0]
          let max = getMiAxder[getMiAxder.length - 1]
          if (mi == max) {
            item.allconfig.pritNUmber = "¥" + mi
          } else {
            item.allconfig.pritNUmber = `¥${mi}~¥${max}`
          }
        }

        let getMiAx = skupriminandmax.sort((a, b) => a - b)
        // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
        let mi = getMiAx[0]
        let max = getMiAx[getMiAx.length - 1]
        if (mi == max) {
          item.allconfig.allPlterNum = mi
          item.allconfig.allPlteprt = "请输入"
        } else {
          item.allconfig.allPlterNum = ""
          item.allconfig.allPlteprt = `${mi}~${max}`
        }

        let kucunMiMx = kucun.sort((a, b) => a - b)
        // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
        let kmi = kucunMiMx[0]
        let kmax = kucunMiMx[kucunMiMx.length - 1]
        if (kmi == kmax) {
          item.allconfig.kuNum = kmi
          item.allconfig.kuTiyrt = "请输入"
        } else {
          item.allconfig.kuNum = ""
          item.allconfig.kuTiyrt = `${kmi}~${kmax}`
        }

        let lincunterMiMx = lincunter.sort((a, b) => a - b)
        // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
        let lmi = lincunterMiMx[0]
        let lmax = lincunterMiMx[lincunterMiMx.length - 1]
        if (lmi == lmax) {
          item.allconfig.linNum = lmi
          item.allconfig.linTiyrt = "请输入"
        } else {
          item.allconfig.linNum = ""
          item.allconfig.linTiyrt = `${lmi}~${lmax}`
        }
      })
      if (mher) {
        // getPritConfigAllData = pritConfigItem[`type${element.upConfug.pritType}AllConfig`]
        element.sku_prd_config = {}
      }
    })
    if (miniStokList && miniStokList.length) {
      Modal.warning({
        title: "提示",
        okText: "知道了",
        width: 460,
        content: (
          <>
            {miniStokList.map((item: any) => {
              return (
                <Space
                  size={12}
                  align="start"
                  style={{
                    fontSize: 12
                  }}>
                  <Tag className="lerwwoiu">活动{item.num}</Tag>
                  <Space direction="vertical">
                    {item.data.map((iuyy) => {
                      return (
                        <Space size={4}>
                          商品：{iuyy.product_id}, 存在库存0sku{" "}
                          <div
                            className="con"
                            style={{
                              color: "#85E08B"
                            }}>
                            已过滤
                          </div>
                        </Space>
                      )
                    })}
                  </Space>
                </Space>
              )
            })}

            {/* {JSON.stringify(miniStokList)} */}
          </>
        ),
        showCancel: false,
        onOk: () => {
          console.log("知道了")
        }
      })
    }
    setAddAllConfigData([...addAllConfigData])
    // 清洗设置sku值
  }
  function fomaterPrice(price, oldPrice, sku_prd_config, skuck, element) {
    const { pritFlot, flotNum, pritType } = sku_prd_config
    if (pritType == "2") {
      return (price * 100).toFixed(0)
    }
    // console.log(price, oldPrice / 100)
    const setPrit = price * 100

    let minPrd = oldPrice * element.miniZekouter
    if (oldPrice - minPrd < 100) {
      minPrd = oldPrice - 100
    }
    const prmPrits = oldPrice - setPrit

    let rtPri = 0

    if (minPrd >= setPrit && prmPrits >= 100) {
      rtPri = ~~setPrit
    } else {
      rtPri = ~~minPrd
    }

    // if
    switch (pritFlot) {
      case "0":
        break
      case "1":
        rtPri = ~~(rtPri / 10) * 10

        break
      case "2":
        rtPri = ~~(rtPri / 100) * 100

        break
      case "3":
        rtPri = ~~(rtPri / 100) * 100 + flotNum * 1
        if (rtPri >= minPrd) {
          rtPri = ~~minPrd
        }

        break
      default:
        break
    }
    // console.log('最低优惠价格', price, oldPrice, sku_prd_config, skuck, element)

    if (
      sku_prd_config.aotoPrtMin &&
      skuck.last_15_day_low_price &&
      rtPri > skuck.last_15_day_low_price
    ) {
      return skuck.last_15_day_low_price
    }
    console.log("132465")

    return rtPri
  }
  const [linNumPx] = useState(
    (() => {
      const list: any = []
      for (let index = 0; index < 20; index++) {
        list.push({
          label: `${index + 1}个`,
          value: index + 1
        })
      }
      return list
    })()
  )
  let errKeys = false
  const [showGoodsTypeStatus, setShowGoodsStatus] = useState(false)

  // 需要渲染创建的结果

  const [upItemAddStatusState, setupItemAddStatusState] = useState<any[]>([])
  const [addUpContentStatus, setAddUpContentStatus] = useState(false)
  const [addUpActAll, setAddUpActAll] = useState(false)
  function upContenProtiuer() {
    if (errKeys) return
    // console.log('这里创建活动')
    setLodinDataStatus(true)
    errKeys = true
    setTimeout(() => {
      errKeys = false
    }, 1500)
    let inouter = 150
    let addGppdNum = 0
    let maxSkuLeng = 1000
    let inSkulen = 0
    let errkey = false
    const upDaters: any = []
    // console.log('addAllConfigData', addAllConfigData)
    addAllConfigData.forEach((record) => {
      addGppdNum = 0
      inSkulen = 0
      // console.log('upDatitem***---', record)
      const upContentData: any = {
        begin_time: record.begin_time, //开始时间
        end_time: record.end_time, //结束时间
        pre_begin_time: record.pre_begin_time, // 预热时间 在选择的时间后面加入
        stype: "7",
        sub_stype: "0",
        activity_type: "26",
        title: "xxx" + record.begin_time,
        time_set_type: "0",
        order_expire_time: record.order_expire_time + "", // 订单取消时间 秒
        shop_stype: (() => {
          if (record.upConfug.pritType == "0") {
            return "1"
          } else if (record.upConfug.pritType == "1") {
            return "2"
          } else if (
            record.upConfug.pritType == "2" ||
            record.upConfug.pritType == "3"
          ) {
            return "3"
          }
        })(), // 1 一口价 // 2直降 3 打折
        sold_out_type: record.sold_out_type + "", // 0恢复原价后继续售卖 1停止售卖
        limit_stock_type: "0",
        business_code: record.business_code, // LimitTime 限时 // LimitQuantity 限量 OrdinaryTimeBuy 普通
        promotion_goods: [],
        config_scope: 0,
        from_page: "",
        need_live: "0"
      }
      // let shopGoodsConter: any = []
      record.selectActPrdlist.forEach((records, index) => {
        // console.log('ww', records)
        let outerNumprt: any = []
        const promotionDoodsData: any = {
          cover: records.img,
          product_id: records.product_id,
          title: records.name,
          channel_id: "0",
          channel_type: 0,
          promotion_skus: []
        }

        records.children.forEach((tuter) => {
          let orderpirs: any = (
            ~~(tuter.origin_price * record.miniZekouter) / 100
          ).toFixed(2)
          const minprt: any =
            orderpirs * 100 - tuter.origin_price >= 100
              ? orderpirs
              : (~~(tuter.origin_price - 100) / 100).toFixed(2)
          // const minprt: any = (tuter.origin_price * record.miniZekouter * 100).toFixed(2)
          const skulist: any = {
            id: tuter.sku_id,
            user_limit: tuter.user_limit,
            camp_stock_num: tuter.camp_stock_num || "0"
          }
          switch (record.upConfug.pritType) {
            case "0":
              // tuter.nowprit = e.target.value
              // console.log('一口价')
              // console.log('输入', e.target.value)
              skulist.price = (tuter.nowprit * 100).toFixed()
              if (!tuter.nowprit) {
                tuter.nock = true
                tuter.altext = `一口价不可为空`
                // setPrtieDta()
                // console.log(1)
                break
              }
              if (
                isNaN(tuter.nowprit * 1) ||
                tuter.nowprit * 1 > minprt * 1 ||
                countDecimalPlaces(tuter.nowprit) > 2
              ) {
                tuter.nock = true
                tuter.altext = `一口价金额≤${minprt}（优惠力度至${record.miniZekouter * 100
                  }折且优惠金额≥1）可精确到小数点后两位`
                // setPrtieDta()
                // console.log(2)
                break
              }
              if (tuter.nowprit * 1 == 0) {
                tuter.nock = true
                tuter.altext = `优惠后的价格须>0`
                // setPrtieDta()
                // console.log(3)
                break
              }
              if (
                tuter.last_15_day_low_price &&
                tuter.nowprit * 1 > tuter.last_15_day_low_price / 100
              ) {
                tuter.nock = true
                tuter.altext = `需小与等于该SKU近15天最低价${(
                  tuter.last_15_day_low_price / 100
                ).toFixed(2)}`
                // setPrtieDta()
                // console.log(4)
                break
              }

              tuter.nock = false
              tuter.altext = ""
              break
            case "1":
              skulist.shop_svalue = (tuter.zhijiangprt * 100).toFixed()
              // tuter.zhijiangprt = e.target.value
              tuter.nowprit = (
                tuter.origin_price / 100 -
                tuter.zhijiangprt
              ).toFixed(2)
              // records.allconfig.pritNUmber = '¥' + tuter.nowprit
              outerNumprt.push(tuter.nowprit)
              // console.log('一口价')
              // console.log('输入', e.target.value)
              const minprtmin: any = (
                (tuter.origin_price * (1 - record.miniZekouter)) /
                100
              ).toFixed(2)
              if (!tuter.zhijiangprt) {
                tuter.nock = true
                tuter.altext = `直降不可为空`
                break
              }

              if (
                isNaN(tuter.nowprit * 1) ||
                tuter.nowprit < 0.01 ||
                tuter.nowprit * 1 > minprt * 1 ||
                countDecimalPlaces(tuter.nowprit) > 2 ||
                tuter.zhijiangprt * 1 == 0
              ) {
                tuter.nock = true
                tuter.altext = `${minprtmin}≤直降金额<${(
                  tuter.origin_price / 100
                ).toFixed(2)}（优惠力度至少${record.miniZekouter * 100
                  }折且优惠金额≥${minprtmin}）可精确到小数点后两位`
                break
              }
              if (
                tuter.last_15_day_low_price &&
                tuter.nowprit * 1 > tuter.last_15_day_low_price / 100
              ) {
                tuter.nock = true
                tuter.altext = `优惠后需小与等于该SKU近15天最低价${(
                  tuter.last_15_day_low_price / 100
                ).toFixed(2)}`
                break
              }
              tuter.nock = false
              tuter.altext = ""
              break
            case "2":
              // tuter.zhijiangprt = e.target.value
              skulist.shop_svalue = (tuter.zhijiangprt * 10).toFixed()
              tuter.nowprit = (
                Math.ceil(
                  ~~(
                    (tuter.origin_price / 100) *
                    (tuter.zhijiangprt / 10) *
                    1000
                  ) / 10
                ) / 100
              ).toFixed(2) //(Math.ceil(~~(tuter.origin_price / 100 * tuter.zhijiangprt / 10 * 100)) / 100).toFixed(2)
              // records.allconfig.pritNUmber = '¥' + tuter.nowprit
              outerNumprt.push(tuter.nowprit)
              // console.log('一口价')
              // console.log('输入', e.target.value)
              // const minprtmin: any = (tuter.origin_price * 0.05 / 100).toFixed(2)
              if (!tuter.zhijiangprt) {
                tuter.nock = true
                tuter.altext = `打折不可为空`
                break
              }
              // console.log(isNaN((tuter.nowprit * 1)))
              // console.log((tuter.origin_price / 100 - tuter.nowprit) < 1 )
              // console.log((tuter.origin_price / 100 - tuter.nowprit) < 1 )
              // console.log(countDecimalPlaces(tuter.zhijiangprt) > 1)
              // console.log(tuter.zhijiangprt < 1 )
              // console.log((tuter.zhijiangprt > (record.miniZekouter * 10)))
              // console.log(tuter.zhijiangprt > (record.miniZekouter * 10))
              if (
                isNaN(tuter.nowprit * 1) ||
                tuter.origin_price / 100 - tuter.nowprit < 1 ||
                countDecimalPlaces(tuter.zhijiangprt) > 1 ||
                tuter.zhijiangprt < 1 ||
                tuter.zhijiangprt > record.miniZekouter * 10
              ) {
                // console.log('record.miniZekouter222', record.miniZekouter, record.miniZekouter * 10)
                // console.log(' tuter.zhijiangprt',  tuter.zhijiangprt)

                // if (isNaN((tuter.nowprit * 1)) || tuter.nowprit < 0.01 || (tuter.nowprit * 1 > minprt * 1) || countDecimalPlaces(tuter.nowprit) > 2 || e.target.value * 1 == 0) {
                tuter.nock = true
                tuter.altext = `打折范围：1.0~${record.miniZekouter * 10
                  }折（优惠力度至少${record.miniZekouter * 100
                  }折且优惠金额≥1）可精确到小数点后一位`
                break
              }
              if (
                tuter.last_15_day_low_price &&
                tuter.nowprit * 1 > tuter.last_15_day_low_price / 100
              ) {
                tuter.nock = true
                tuter.altext = `优惠后需小与等于该SKU近15天最低价${(
                  tuter.last_15_day_low_price / 100
                ).toFixed(2)}`
                break
              }
              tuter.nock = false
              tuter.altext = ""
              break
            default:
              break
          }
          if (upContentData.business_code !== "OrdinaryTimeBuy") {
            if (!tuter.camp_stock_num || isNaN(tuter.camp_stock_num * 1)) {
              tuter.kuerr = true
              tuter.kuText = "活动库存不正常"
            }
          }
          if (upContentData.business_code == "OrdinaryTimeBuy") {
            skulist.camp_stock_num = "0"
          }
          if (
            record.business_code === "LimitQuantity" &&
            tuter.camp_stock_num > 1000
          ) {
            tuter.kuerr = true
            tuter.kuText = "限量抢购最大库存为1000"
          }
          if (tuter.kuerr) {
            records.allconfig.kuErr = true
            records.allconfig.kuErrText = "部分SKU库存填写错误，请展开查看"
            errkey = true
          }
          if (tuter.nock) {
            records.allconfig.allErrstatus = true
            records.allconfig.allErrText = "部分SKU填写错误，请展开查看"
            errkey = true
          }
          inSkulen++

          promotionDoodsData.promotion_skus.push(skulist)
          // records.allconfig.allPlteprt = '请输入'
        })
        if (outerNumprt && outerNumprt.length) {
          let getMiAxder = outerNumprt.sort((a, b) => a - b)
          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
          let mi = getMiAxder[0]
          let max = getMiAxder[getMiAxder.length - 1]
          if (mi == max) {
            records.allconfig.pritNUmber = "¥" + mi
          } else {
            records.allconfig.pritNUmber = `¥${mi}~¥${max}`
          }
        }
        let titleConte = ""
        switch (upContentData.business_code) {
          case "LimitTime":
            titleConte = `限时总${record.selectActPrdlist.length}内${addGppdNum + 1
              } ${moment(upContentData.begin_time).format("YYYYMMDD HHmmss")}`
            break
          case "LimitQuantity":
            titleConte = `限量总${record.selectActPrdlist.length}内${addGppdNum + 1
              } ${moment(upContentData.begin_time).format("YYYYMMDD HHmmss")}`
            break
          case "OrdinaryTimeBuy":
            upContentData.limit_stock_type = "1"
            // upContentData.camp_stock_num = '0'
            titleConte = `普通总${record.selectActPrdlist.length}内${addGppdNum + 1
              } ${moment(upContentData.begin_time).format("YYYYMMDD HHmmss")}`
            break
          default:
            break
        }
        upContentData.title = titleConte.slice(0, 25) //
        if (inouter > addGppdNum) {
          // 还没有到200个商品
          if (inSkulen < maxSkuLeng) {
            // 还没到2000个sku
            upContentData.promotion_goods.push(promotionDoodsData)
            addGppdNum++
            if (index === record.selectActPrdlist.length - 1) {
              upDaters.push(JSON.parse(JSON.stringify(upContentData)))
            }
          } else {
            upContentData.promotion_goods.push(promotionDoodsData)

            upContentData.title = titleConte.slice(0, 25) //
            upDaters.push(JSON.parse(JSON.stringify(upContentData)))
            upContentData.promotion_goods = []

            inSkulen = 0
            addGppdNum = 0
          }
        } else {
          upContentData.promotion_goods.push(promotionDoodsData)

          upContentData.title = titleConte.slice(0, 25) //
          upDaters.push(JSON.parse(JSON.stringify(upContentData)))
          upContentData.promotion_goods = []

          inSkulen = 0
          addGppdNum = 0
        }
      })
    })
    if (errkey) {
      Modal.error({
        title: "提示",
        content: "存在未完成配置的活动项，请完成后创建",
        okText: "知道了",
        showCancel: false,
        onOk: () => {
          setLodinDataStatus(false)
        }
      })

      setAddAllConfigData([...addAllConfigData])
    } else {
      // console.log('创建数据这里需要渲染出来', upDaters)
      setAddUpContentStatus(true)
      setLodinDataStatus(true)
      setAddUpActAll(false)
      window.onbeforeunload = function (event) {
        return "您正在创建优惠券，是否确认离开" // 新版本浏览器不起作用
      }
      // 走递归处理
      const upItemAddStatus = upDaters.map((item, index) => {
        const uptData = {
          indexkey: index,
          status: 0, // 0等待 1 进行中 2 成功 3 失败
          msg: "等待创建",
          data: item
        }
        return uptData
      })
      setupItemAddStatusState([...upItemAddStatus])
      upAddActFunDG(0)
      function upAddActFunDG(index) {
        if (index === upItemAddStatus.length) {
          addAllConfigData.forEach((itemser) => {
            itemser.selectActPrdlist = []
          })
          setAddAllConfigData([...addAllConfigData])
          window.onbeforeunload = null
          Modal.success({
            title: "创建成功",
            content: `已成功创建${upItemAddStatus.length}个活动!`
          })
          setAddUpActAll(true)
          setLodinDataStatus(false)
          return
        }
        upItemAddStatus[index].status = 1
        upItemAddStatus[index].msg = "正在创建"
        setupItemAddStatusState([...upItemAddStatus])
        createPromotion(upItemAddStatus[index].data).then((res: any) => {
          if (!res.code) {
            upItemAddStatus[index].status = 2
            upItemAddStatus[index].msg = "创建成功"
            setupItemAddStatusState([...upItemAddStatus])
            index++
            upAddActFunDG(index)
          } else {
            upItemAddStatus[index].status = 3
            upItemAddStatus[index].msg = "创建失败" + res.msg
            setupItemAddStatusState([...upItemAddStatus])
            index++
            upAddActFunDG(index)
          }
        })
      }
    }
  }
  const addUpActDataTabs: ColumnProps<ColumnPropsType>[] = [
    {
      title: "序号",
      key: "0",
      align: "center",
      // width: 110,
      render: (text: any, record: any, index: number) => {
        return index + 1
      }
    },
    {
      title: "活动名称",
      key: "1",
      align: "center",
      width: 280,
      render: (text: any, record: any, index: number) => {
        return record.data.title
      }
    },
    {
      title: "商品数量",
      key: "1",
      align: "center",
      // width: 280,
      render: (text: any, record: any, index: number) => {
        return record.data.promotion_goods.length
      }
    },
    {
      title: "SKU数量",
      key: "1",
      align: "center",
      // width: 280,
      render: (text: any, record: any, index: number) => {
        let infoAddConter = 0
        record.data.promotion_goods.forEach((item) => {
          infoAddConter += item.promotion_skus.length
        })
        return infoAddConter
      }
    },
    {
      title: "活动类型",
      key: "2",
      align: "center",
      // width: 110,
      render: (text: any, record: any, index: number) => {
        return record.data.business_code === "LimitTime"
          ? "限时抢购"
          : record.data.business_code === "LimitQuantity"
            ? "限量抢购"
            : "普通降价促销"
      }
    },
    {
      title: "活动时间",
      key: "3",
      align: "center",
      width: 280,
      render: (text: any, record: any, index: number) => {
        return (
          <>
            <p>{record.data.begin_time}</p>
            <p>{record.data.end_time}</p>
          </>
        )
      }
    },
    {
      title: "促销类型",
      key: "4",
      align: "center",
      // width: 110,
      render: (text: any, record: any, index: number) => {
        return record.data.shop_stype == "1"
          ? "一口价"
          : record.data.shop_stype == "2"
            ? "直降"
            : "打折"
      }
    },
    {
      title: "状态",
      key: "5",
      align: "center",
      // width: 150,
      render: (text: any, record: any, index: number) => {
        // 区分颜色
        return (
          <>
            {record.status == 0 ? (
              <span>{record.msg}</span>
            ) : record.status == 1 ? (
              <>
                <Icon.LoadingIcon
                  svgProps={{ style: { width: "12px", height: "12px" } }}
                />
                {record.msg}
              </>
            ) : record.status == 2 ? (
              <span style={{ color: "#3CC781" }}>{record.msg}</span>
            ) : (
              <span style={{ color: "red" }}>{record.msg}</span>
            )}
          </>
        )
      }
    }
  ]
  return (
    <div>
      <Spin spinning={lodinDataStatus}>
        <Space
          direction="vertical"
          style={{
            width: "100%"
          }}>
          <Space
            style={{
              width: "100%",
              justifyContent: "space-between"
            }}>
            <Space>
              <Button
                type="primary"
                size="mini"
                icon={<Icon type="AddIcon" />}
                onClick={() => {
                  setEditLtalpStatus({
                    status: false,
                    index: -1
                  })
                  setShowAddContent(true)
                }}>
                添加活动
              </Button>
              <Tooltip title="抖店每个活动sku不能超过 2000 个sku，每个活动不能超过200个商品，软件会根据当前所选商品情况自动调整活动的商品数量创建活动">
                <Icon
                  type="DoubtIcon"
                  style={{
                    cursor: "pointer"
                  }}></Icon>
              </Tooltip>
            </Space>

            <Button
              loading={lodinRefoGoodsLodin}
              disabled={lodinRefoGoodsLodin}
              type="primary"
              size="mini"
              icon={<Icon type="RefreshIcon" />}
              onClick={() => {
                setlodinRefoGoodsLodin(true)
                getGoodsList().then((res) => {
                  message.success("商品列表已刷新")
                })
              }}>
              刷新商品列表
            </Button>
          </Space>

          <Table
            // className="custom-style-gray"
            // scroll={{ y: 830 }}
            style={{
              width: "100%"
              // height: 900
            }}
            columns={selectConfigTable}
            dataSource={addAllConfigData}
            pagination={false}
            rowKey="indexkey"
            expandable={{
              indentSize: 1,
              expandRowByClick: true,
              expandedRowClassName: (record, index) => {
                return "expandable-sub-table noutermotern"
                // return index === 1 ? 'expandable-sub-table' : '';
              },
              // defaultExpandAllRows: true,
              expandedRowKeys: actOpenKeys,
              onExpand: (expanded, records) => {
                if (expanded) {
                  actOpenKeys.push(records.indexkey)
                } else {
                  actOpenKeys.splice(actOpenKeys.indexOf(records.indexkey), 1)
                }
                // console.log('点击展开', expanded, records, record)
                setactOpenKeys([...actOpenKeys])
              },
              expandedRowRender: (record: any, index: number) => {
                return (
                  <div>
                    <Table
                      rowClassName="row-vertical-top"
                      // bordered
                      size="small"
                      // className="custom-style-gray"
                      loading={lodinDataStatus}
                      columns={[
                        {
                          title: "商品信息",
                          key: "11",
                          align: "left",
                          width: 310,
                          className: "hternsghr",
                          render: (text: any, record: any) => {
                            if (!record.children) {
                              return null
                            }
                            return (
                              <Space align="center">
                                <ImgDefault
                                  imgSrc={(() => {
                                    const imgae = record.img.replace("obj/", "")
                                    return imgae + "~60x60_q75.image"
                                  })()}
                                  mask={false}
                                  width={60}
                                  height={60}></ImgDefault>
                                <Space direction="vertical" size={4}>
                                  <Tooltip.Auto
                                    title={record.name}
                                    lineClamp={1}>
                                    <div
                                      className="title"
                                      style={{
                                        fontSize: 12,
                                        color: "#252931",
                                        width: 150
                                      }}>
                                      {record.name}
                                    </div>
                                  </Tooltip.Auto>

                                  <div
                                    className="isduer"
                                    style={{
                                      color: "#898b8f",
                                      fontSize: 12
                                    }}>
                                    ID:{record.product_id}
                                    <Icon
                                      type="CopyIcon"
                                      className="copyiconitem"
                                      style={{
                                        marginLeft: 5,
                                        cursor: "pointer"
                                      }}
                                      onClick={() =>
                                        copyToClipboard(record.product_id)
                                      }
                                    />
                                  </div>
                                  <div
                                    className="isduer"
                                    style={{
                                      color: "#898b8f",
                                      fontSize: 12
                                    }}>
                                    总库存:{record.stock_num}
                                  </div>
                                </Space>
                              </Space>
                            )
                          }
                        },
                        {
                          title: "规格信息",
                          key: "2",
                          align: "left",
                          ellipsis: true,
                          render: (_, record: any, index: number) => {
                            if (!record.children) {
                              return (
                                <Space>
                                  <ImgDefault
                                    imgSrc={(() => {
                                      if (!record.img.includes("obj/")) {
                                        return record.img
                                      }
                                      const imgae = record.img.replace(
                                        "obj/",
                                        ""
                                      )
                                      return imgae + "~30x30_q75.image"
                                    })()}
                                    mask={false}
                                    width={30}
                                    height={30}></ImgDefault>
                                  <Space direction="vertical" size={4}>
                                    <Tooltip.Auto
                                      title={record.specification}
                                      lineClamp={1}>
                                      <div
                                        className="title"
                                        style={{
                                          fontSize: 12,
                                          color: "#252931",
                                          width: 120
                                        }}>
                                        {record.specification}
                                      </div>
                                    </Tooltip.Auto>
                                    <div
                                      className="isduer"
                                      style={{
                                        color: "#898b8f",
                                        fontSize: 12
                                      }}>
                                      原价:
                                      {(record.origin_price / 100).toFixed(2)}
                                    </div>
                                  </Space>
                                </Space>
                              )
                            }
                            // console.log('_, record', _, record, index)
                            if (record.min_price === record.max_price) {
                              return (record.min_price / 100).toFixed(2)
                            }
                            return `￥${(record.min_price / 100).toFixed(
                              2
                            )} ~ ￥${(record.max_price / 100).toFixed(2)}`
                          }
                        },
                        {
                          title: (_) => {
                            // console.log('record_____-----', _, index, record)
                            let conterkey = false
                            // 这里需要现在使用
                            if (!chengeSopterkey) {
                              if (
                                record.selectConfigIndex !== -1 &&
                                configDataUse[record.selectConfigIndex]
                              ) {
                                conterkey = true
                                record.sku_prd_config =
                                  configDataUse[record.selectConfigIndex]
                              }
                              record.upConfug.pritType =
                                record.sku_prd_config?.pritType ||
                                record.upConfug.pritType
                            }

                            return (
                              <Tooltip
                                title={
                                  conterkey
                                    ? "已添加sku价格配置无法修改, 请到下方sku几个配置中编辑"
                                    : ""
                                }>
                                <Select
                                  size="small"
                                  disabled={conterkey}
                                  value={
                                    record.upConfug.pritType === "3"
                                      ? "2"
                                      : record.upConfug.pritType
                                  }
                                  style={{ width: 120 }}
                                  bordered={false}
                                  onChange={(e) => {
                                    console.log("e", e)
                                    // 切换后转换价格
                                    record.selectActPrdlist.forEach(
                                      (recordno) => {
                                        // console.log('itemk----', recordno)
                                        recordno.allconfig.allErrstatus = false
                                        recordno.allconfig.allErrText = ""
                                        let outerNumprt: any = []
                                        let nouter: any = []
                                        recordno.children.forEach((records) => {
                                          // console.log('itemk', records)

                                          // const minprt: any = (~~(records.origin_price * record.miniZekouter) / 100).toFixed(2)
                                          let orderpirs: any = (
                                            ~~(
                                              records.origin_price *
                                              record.miniZekouter
                                            ) / 100
                                          ).toFixed(2)
                                          const minprt: any =
                                            orderpirs * 100 -
                                              records.origin_price >=
                                              100
                                              ? orderpirs
                                              : (
                                                ~~(
                                                  records.origin_price - 100
                                                ) / 100
                                              ).toFixed(2)
                                          switch (e) {
                                            case "0":
                                              // console.log('record.upConfug.pritType', record.upConfug.pritType)

                                              if (
                                                record.upConfug.pritType == "1"
                                              ) {
                                                records.nowprit = (
                                                  Math.ceil(
                                                    ~~(
                                                      (records.origin_price /
                                                        100 -
                                                        records.zhijiangprt) *
                                                      1000
                                                    ) / 10
                                                  ) / 100
                                                ).toFixed(2)
                                              }
                                              if (
                                                record.upConfug.pritType == "2"
                                              ) {
                                                records.nowprit ==
                                                  (
                                                    Math.ceil(
                                                      ~~(
                                                        (records.origin_price /
                                                          100 -
                                                          records.zhijiangprt) *
                                                        1000
                                                      ) / 10
                                                    ) / 100
                                                  ).toFixed(2)
                                                // records.nowprit = (records.origin_price * records.zhijiangprt).toFixed(2)
                                              }
                                              nouter.push(records.nowprit)
                                              if (!records.nowprit) {
                                                records.nock = true
                                                records.altext = `一口价不可为空`
                                              }
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.nowprit * 1 >
                                                minprt * 1 ||
                                                countDecimalPlaces(
                                                  records.nowprit
                                                ) > 2
                                              ) {
                                                records.nock = true
                                                records.altext = `一口价金额≤${minprt}（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥1）可精确到小数点后两位`
                                                // setPrtieDta()
                                                console.log(2)
                                                break
                                              }
                                              if (records.nowprit * 1 == 0) {
                                                records.nock = true
                                                records.altext = `优惠后的价格须>0`
                                                // setPrtieDta()
                                                console.log(3)
                                                break
                                              }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break
                                            case "1":
                                              // console.log('record.upConfug.pritType', record.upConfug.pritType)
                                              if (
                                                record.upConfug.pritType == "0"
                                              ) {
                                                records.zhijiangprt = (
                                                  records.origin_price / 100 -
                                                  records.nowprit
                                                ).toFixed(2)
                                              }
                                              if (
                                                record.upConfug.pritType == "2"
                                              ) {
                                                records.zhijiangprt = (
                                                  records.origin_price / 100 -
                                                  (records.origin_price / 100) *
                                                  (records.zhijiangprt / 10)
                                                ).toFixed(2)
                                                //((records.origin_price / 100) - (Math.ceil(records.origin_price / 100 * (records.zhijiangprt / 10) * 100) / 100)).toFixed(2)
                                              }
                                              nouter.push(records.zhijiangprt)
                                              records.nowprit =
                                                records.zhijiangprt
                                                  ? (
                                                    Math.ceil(
                                                      ~~(
                                                        (records.origin_price /
                                                          100) *
                                                        (records.zhijiangprt /
                                                          10) *
                                                        1000
                                                      ) / 10
                                                    ) / 100
                                                  ).toFixed(2)
                                                  : "" // (Math.ceil((~~(records.origin_price / 100 - records.zhijiangprt) * 100)) / 100).toFixed(2)
                                              const minprtmin: any = (
                                                (records.origin_price *
                                                  (1 - record.miniZekouter)) /
                                                100
                                              ).toFixed(2)
                                              outerNumprt.push(records.nowprit)
                                              if (!records.zhijiangprt) {
                                                records.nock = true
                                                records.altext = `直降不可为空`
                                                // setPrtieDta()
                                                // console.log(1)
                                                break
                                              }
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.nowprit < 0.01 ||
                                                records.nowprit * 1 >
                                                minprt * 1 ||
                                                countDecimalPlaces(
                                                  records.zhijiangprt
                                                ) > 2 ||
                                                records.zhijiangprt * 1 == 0
                                              ) {
                                                records.nock = true
                                                records.altext = `${minprtmin}≤直降金额<${(
                                                  records.origin_price / 100
                                                ).toFixed(2)}（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥${minprtmin}）可精确到小数点后两位`
                                                // records.altext = `一口价金额≤${minprt}（优惠力度至少95折且优惠金额≥1）可精确到小数点后两位`
                                                // setPrtieDta()
                                                // console.log(2)
                                                break
                                              }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                // console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break
                                            case "2":
                                              // console.log('record.upConfug.pritType', record.upConfug.pritType)

                                              if (
                                                record.upConfug.pritType == "0"
                                              ) {
                                                records.zhijiangprt = (
                                                  (records.nowprit /
                                                    (records.origin_price /
                                                      100)) *
                                                  10
                                                ).toFixed(1)
                                              }
                                              if (
                                                record.upConfug.pritType == "1"
                                              ) {
                                                records.zhijiangprt = (
                                                  ((records.origin_price / 100 -
                                                    records.zhijiangprt) /
                                                    (records.origin_price /
                                                      100)) *
                                                  10
                                                ).toFixed(1)
                                              }
                                              records.nowprit =
                                                records.zhijiangprt
                                                  ? (
                                                    Math.ceil(
                                                      ~~(
                                                        (records.origin_price /
                                                          100) *
                                                        (records.zhijiangprt /
                                                          10) *
                                                        1000
                                                      ) / 10
                                                    ) / 100
                                                  ).toFixed(2)
                                                  : "" // (Math.ceil(~~(records.origin_price / 100 * (records.zhijiangprt / 10) * 100)) / 100).toFixed(2)
                                              outerNumprt.push(records.nowprit)
                                              nouter.push(records.zhijiangprt)
                                              if (!records.zhijiangprt) {
                                                records.nock = true
                                                records.altext = `打折不可为空`
                                                // // setPrtieDta()
                                                // console.log(1)
                                                break
                                              }
                                              // console.log('isNaN((records.nowprit * 1))', isNaN((records.nowprit * 1)))
                                              // console.log('(records.origin_price / 100 - records.nowprit) < 1', (records.origin_price / 100 - records.nowprit) < 1)
                                              // console.log('countDecimalPlaces(records.zhijiangprt) > 1', countDecimalPlaces(records.zhijiangprt) > 1)
                                              // console.log('records.zhijiangprt < 1', records.zhijiangprt < 1)
                                              // console.log('(records.zhijiangprt > (record.miniZekouter * 10))', (records.zhijiangprt > (record.miniZekouter * 10)))
                                              // console.log('isNaN((records.nowprit * 1))', isNaN((records.nowprit * 1)))
                                              // console.log('isNaN((records.nowprit * 1))', isNaN((records.nowprit * 1)))
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.origin_price / 100 -
                                                records.nowprit <
                                                1 ||
                                                countDecimalPlaces(
                                                  records.zhijiangprt
                                                ) > 1 ||
                                                records.zhijiangprt < 1 ||
                                                records.zhijiangprt >
                                                record.miniZekouter * 10
                                              ) {
                                                // console.log('record.miniZekouter', record.miniZekouter)
                                                // console.log('records.zhijiangprt', records.zhijiangprt)
                                                records.nock = true
                                                records.altext = `打折范围：1.0~${record.miniZekouter * 10
                                                  }折（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥1）可精确到小数点后一位`
                                                // records.altext = `一口价金额≤${minprt}（优惠力度至少95折且优惠金额≥1）可精确到小数点后两位`
                                                // setPrtieDta()
                                                // console.log(2)
                                                break
                                              }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                // console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break
                                            default:
                                              break
                                          }
                                          if (records.nock) {
                                            recordno.allconfig.allErrstatus =
                                              true
                                            recordno.allconfig.allErrText =
                                              "部分SKU一口价填写错误，请展开查看"
                                          }
                                          recordno.allconfig.allPlteprt =
                                            "请输入"
                                        })
                                        if (outerNumprt && outerNumprt.length) {
                                          let getMiAxder = outerNumprt.sort(
                                            (a, b) => a - b
                                          )
                                          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
                                          let mi = getMiAxder[0]
                                          let max =
                                            getMiAxder[getMiAxder.length - 1]
                                          if (mi == max) {
                                            recordno.allconfig.pritNUmber =
                                              "¥" + mi
                                            // recordno.allconfig.allPlterNum = mi
                                          } else {
                                            // recordno.allconfig.allPlterNum = ''
                                            recordno.allconfig.pritNUmber = `¥${mi}~¥${max}`
                                            // recordno.allconfig.allPlteprt = `${mi}~${max}`
                                          }
                                        }
                                        if (nouter && nouter.length) {
                                          let getMiAxder = nouter.sort(
                                            (a, b) => a - b
                                          )
                                          // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
                                          let mi = getMiAxder[0]
                                          let max =
                                            getMiAxder[getMiAxder.length - 1]
                                          if (mi == max) {
                                            // recordno.allconfig.pritNUmber = '¥' + mi
                                            recordno.allconfig.allPlterNum = mi
                                          } else {
                                            recordno.allconfig.allPlterNum = ""
                                            // recordno.allconfig.pritNUmber = `¥${mi}~¥${max}`
                                            recordno.allconfig.allPlteprt = `${mi}~${max}`
                                          }
                                        }
                                      }
                                    )
                                    record.upConfug.pritType = e

                                    setAddAllConfigData([...addAllConfigData])
                                    chengeSopterkey = true
                                    setTimeout(() => {
                                      chengeSopterkey = false
                                    }, 1000)
                                  }}>
                                  <Option value="0">一口价</Option>
                                  <Option value="1">直降</Option>
                                  <Option value="2">打折</Option>
                                </Select>
                              </Tooltip>
                            )
                          },
                          key: "3",
                          align: "left",
                          render: (_, records: any, index: number) => {
                            if (!records.children) {
                              return (
                                <Form>
                                  <Form.Item
                                    extra={
                                      record.upConfug.pritType === "1"
                                        ? "降后价:" + records.nowprit
                                        : record.upConfug.pritType === "2"
                                          ? "打折后:" + records.nowprit
                                          : ""
                                    }
                                    validateStatus={records.nock ? "error" : ""}
                                    className="errOncter">
                                    <Input
                                      notice={
                                        records.nock ? records.altext : ""
                                      }
                                      noticeType={
                                        records.nock ? "error" : undefined
                                      }
                                      placeholder={
                                        record.upConfug.pritType === "0"
                                          ? `≤${records.miniprit}`
                                          : record.upConfug.pritType === "1"
                                            ? "≥1"
                                            : record.upConfug.pritType === "2"
                                              ? `1.0~${record.miniZekouter * 10}`
                                              : ""
                                      }
                                      size="small"
                                      suffix={
                                        record.upConfug.pritType === "0" ||
                                          record.upConfug.pritType === "1"
                                          ? "元"
                                          : "折"
                                      }
                                      value={
                                        record.upConfug.pritType === "0"
                                          ? records.nowprit
                                          : record.upConfug.pritType === "1" ||
                                            record.upConfug.pritType === "2"
                                            ? records.zhijiangprt
                                            : ""
                                      }
                                      onChange={(e: any) => {
                                        let orderpirs: any = (
                                          ~~(
                                            records.origin_price *
                                            record.miniZekouter
                                          ) / 100
                                        ).toFixed(2)
                                        const minprt: any =
                                          orderpirs * 100 -
                                            records.origin_price >=
                                            100
                                            ? orderpirs
                                            : (
                                              ~~(records.origin_price - 100) /
                                              100
                                            ).toFixed(2)

                                        switch (record.upConfug.pritType) {
                                          case "0":
                                            records.nowprit = e.target.value

                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)
                                            if (!e.target.value) {
                                              records.nock = true
                                              records.altext = `一口价不可为空`
                                              // setPrtieDta()
                                              // console.log(1)
                                              break
                                            }
                                            if (
                                              isNaN(e.target.value * 1) ||
                                              e.target.value * 1 > minprt * 1 ||
                                              countDecimalPlaces(
                                                e.target.value
                                              ) > 2
                                            ) {
                                              records.nock = true
                                              records.altext = `一口价金额≤${minprt}（优惠力度至少${record.miniZekouter * 100
                                                }折且优惠金额≥1）可精确到小数点后两位`
                                              // setPrtieDta()
                                              console.log(2)
                                              break
                                            }
                                            if (e.target.value * 1 == 0) {
                                              records.nock = true
                                              records.altext = `优惠后的价格须>0`
                                              // setPrtieDta()
                                              console.log(3)
                                              break
                                            }
                                            if (
                                              records.last_15_day_low_price &&
                                              e.target.value * 1 >
                                              records.last_15_day_low_price /
                                              100
                                            ) {
                                              records.nock = true
                                              records.altext = `需小与等于该SKU近15天最低价${(
                                                records.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              // setPrtieDta()
                                              console.log(4)
                                              break
                                            }
                                            records.nock = false
                                            records.altext = ""
                                            break
                                          case "1":
                                            records.zhijiangprt = e.target.value
                                            records.nowprit = (
                                              records.origin_price / 100 -
                                              e.target.value
                                            ).toFixed(2)
                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)
                                            const minprtmin: any = (
                                              (records.origin_price *
                                                (1 - record.miniZekouter)) /
                                              100
                                            ).toFixed(2)
                                            if (!e.target.value) {
                                              records.nock = true
                                              records.altext = `直降不可为空`
                                              // setPrtieDta()
                                              // console.log(1)
                                              break
                                            }
                                            if (
                                              isNaN(records.nowprit * 1) ||
                                              records.nowprit < 0.01 ||
                                              records.nowprit * 1 >
                                              minprt * 1 ||
                                              countDecimalPlaces(
                                                records.zhijiangprt
                                              ) > 2 ||
                                              e.target.value * 1 == 0
                                            ) {
                                              records.nock = true
                                              records.altext = `${minprtmin}≤直降金额<${(
                                                records.origin_price / 100
                                              ).toFixed(2)}（优惠力度至少${record.miniZekouter * 100
                                                }折且优惠金额≥${minprtmin}）可精确到小数点后两位`
                                              // records.altext = `一口价金额≤${minprt}（优惠力度至少95折且优惠金额≥1）可精确到小数点后两位`
                                              // setPrtieDta()
                                              // console.log(2)
                                              break
                                            }
                                            // if (e.target.value * 1 == 0) {
                                            //     records.nock = true
                                            //     records.altext = `优惠后的价格须>0`
                                            //     // setPrtieDta()
                                            //     console.log(3)
                                            //     break
                                            // }
                                            if (
                                              records.last_15_day_low_price &&
                                              records.nowprit * 1 >
                                              records.last_15_day_low_price /
                                              100
                                            ) {
                                              records.nock = true
                                              records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                records.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              // setPrtieDta()
                                              // console.log(4)
                                              break
                                            }
                                            records.nock = false
                                            records.altext = ""
                                            break
                                          case "2":
                                            records.zhijiangprt = e.target.value
                                            records.nowprit = (
                                              Math.ceil(
                                                ~~(
                                                  (records.origin_price / 100) *
                                                  (e.target.value / 10) *
                                                  1000
                                                ) / 10
                                              ) / 100
                                            ).toFixed(2) // (Math.ceil(~~(records.origin_price / 100 * (e.target.value / 10) * 100)) / 100).toFixed(2)
                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)
                                            // const minprtmin: any = (records.origin_price * 0.05 / 100).toFixed(2)
                                            if (!e.target.value) {
                                              records.nock = true
                                              records.altext = `打折不可为空`
                                              // // setPrtieDta()
                                              // console.log(1)
                                              break
                                            }
                                            if (
                                              isNaN(records.nowprit * 1) ||
                                              records.origin_price / 100 -
                                              records.nowprit <
                                              1 ||
                                              countDecimalPlaces(
                                                records.zhijiangprt
                                              ) > 1 ||
                                              records.zhijiangprt < 1 ||
                                              records.zhijiangprt >
                                              record.miniZekouter * 10
                                            ) {
                                              // console.log('record.miniZekouter', record.miniZekouter)
                                              // console.log('records.zhijiangprt', records.zhijiangprt)
                                              records.nock = true
                                              records.altext = `打折范围：1.0~${record.miniZekouter * 10
                                                }折（优惠力度至少${record.miniZekouter * 100
                                                }折且优惠金额≥1）可精确到小数点后一位`
                                              // records.altext = `一口价金额≤${minprt}（优惠力度至少95折且优惠金额≥1）可精确到小数点后两位`
                                              // setPrtieDta()
                                              // console.log(2)
                                              break
                                            }
                                            // if (e.target.value * 1 == 0) {
                                            //     records.nock = true
                                            //     records.altext = `优惠后的价格须>0`
                                            //     // setPrtieDta()
                                            //     console.log(3)
                                            //     break
                                            // }
                                            if (
                                              records.last_15_day_low_price &&
                                              records.nowprit * 1 >
                                              records.last_15_day_low_price /
                                              100
                                            ) {
                                              records.nock = true
                                              records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                records.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              // setPrtieDta()
                                              // console.log(4)
                                              break
                                            }
                                            records.nock = false
                                            records.altext = ""
                                            break
                                          default:
                                            break
                                        }
                                        // console.log('判断情况', record, records, index)
                                        const fingChengSkuList =
                                          record.selectActPrdlist.find(
                                            (itemsdrt) => {
                                              return (
                                                itemsdrt.product_id ==
                                                records.product_id
                                              )
                                            }
                                          )
                                        let outerNumprt: any = []
                                        if (fingChengSkuList) {
                                          fingChengSkuList.allconfig.allErrstatus =
                                            false
                                          fingChengSkuList.allconfig.allErrText =
                                            ""
                                          let skupriminandmax =
                                            fingChengSkuList.children
                                              .map((iter) => {
                                                if (iter.nock) {
                                                  fingChengSkuList.allconfig.allErrstatus =
                                                    true
                                                  fingChengSkuList.allconfig.allErrText =
                                                    "部分SKU填写错误，请展开查看"
                                                }
                                                outerNumprt.push(
                                                  isNaN(iter.nowprit * 1)
                                                    ? false
                                                    : iter.nowprit || "0"
                                                )

                                                if (
                                                  record.upConfug.pritType ==
                                                  "0"
                                                ) {
                                                  return isNaN(iter.nowprit * 1)
                                                    ? false
                                                    : iter.nowprit || "0"
                                                }
                                                if (
                                                  record.upConfug.pritType ==
                                                  "1" ||
                                                  record.upConfug.pritType ==
                                                  "2"
                                                ) {
                                                  return isNaN(
                                                    iter.zhijiangprt * 1
                                                  )
                                                    ? false
                                                    : iter.zhijiangprt || "0"
                                                }
                                                return 12
                                              })
                                              .sort((a, b) => a - b)
                                              .filter((biner) => biner)
                                          if (
                                            outerNumprt &&
                                            outerNumprt.length
                                          ) {
                                            let getMiAxder = outerNumprt.sort(
                                              (a, b) => a - b
                                            )
                                            // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
                                            let mi = getMiAxder[0]
                                            let max =
                                              getMiAxder[getMiAxder.length - 1]
                                            if (mi == max) {
                                              fingChengSkuList.allconfig.pritNUmber =
                                                "¥" + mi
                                            } else {
                                              fingChengSkuList.allconfig.pritNUmber = `¥${mi}~¥${max}`
                                            }
                                          }
                                          let mi = skupriminandmax[0]
                                          let max =
                                            skupriminandmax[
                                            skupriminandmax.length - 1
                                            ]
                                          if (mi == max) {
                                            if (mi == "0") {
                                              fingChengSkuList.allconfig.allPlterNum =
                                                ""
                                              fingChengSkuList.allconfig.allPlteprt =
                                                "请输入"
                                            } else {
                                              fingChengSkuList.allconfig.allPlterNum =
                                                mi
                                              fingChengSkuList.allconfig.allPlteprt =
                                                ""
                                            }
                                            // fingChengSkuList.allconfig.allPlterNum = mi
                                            // fingChengSkuList.allconfig.allPlteprt = ''
                                          } else {
                                            fingChengSkuList.allconfig.allPlterNum =
                                              ""
                                            fingChengSkuList.allconfig.allPlteprt = `${mi}~${max}`
                                          }
                                          // fingChengSkuList
                                        }
                                        setAddAllConfigData([
                                          ...addAllConfigData
                                        ])
                                      }}></Input>
                                  </Form.Item>
                                </Form>
                              )
                            }
                            return (
                              <Form>
                                <Form.Item
                                  extra={
                                    record.upConfug.pritType === "1"
                                      ? "降后价:" + records.allconfig.pritNUmber
                                      : record.upConfug.pritType === "2"
                                        ? "打折后:" + records.allconfig.pritNUmber
                                        : ""
                                  }
                                  validateStatus={
                                    records.allconfig.allErrstatus
                                      ? "error"
                                      : ""
                                  }
                                  className="errOncter">
                                  <Input
                                    notice={
                                      records.allconfig.allErrstatus
                                        ? records.allconfig.allErrText
                                        : ""
                                    }
                                    noticeType={
                                      records.allconfig.allErrstatus
                                        ? "error"
                                        : undefined
                                    }
                                    value={records.allconfig.allPlterNum}
                                    placeholder={records.allconfig.allPlteprt}
                                    size="small"
                                    suffix={
                                      record.upConfug.pritType === "0" ||
                                        record.upConfug.pritType === "1"
                                        ? "元"
                                        : "折"
                                    }
                                    onChange={(e: any) => {
                                      records.allconfig.allPlterNum =
                                        e.target.value
                                      records.allconfig.allErrstatus = false
                                      records.allconfig.allErrText = ""
                                      let outerNumprt: any = []

                                      records.children.forEach((tuter) => {
                                        // const minprt: any = (tuter.origin_price * record.miniZekouter * 100).toFixed(2)
                                        let orderpirs: any = (
                                          ~~(
                                            tuter.origin_price *
                                            record.miniZekouter
                                          ) / 100
                                        ).toFixed(2)
                                        const minprt: any =
                                          orderpirs * 100 -
                                            tuter.origin_price >=
                                            100
                                            ? orderpirs
                                            : (
                                              ~~(tuter.origin_price - 100) /
                                              100
                                            ).toFixed(2)
                                        switch (record.upConfug.pritType) {
                                          case "0":
                                            tuter.nowprit = e.target.value
                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)

                                            if (!e.target.value) {
                                              tuter.nock = true
                                              tuter.altext = `一口价不可为空`
                                              // setPrtieDta()
                                              console.log(1)
                                              break
                                            }
                                            if (
                                              isNaN(e.target.value * 1) ||
                                              e.target.value * 1 > minprt * 1 ||
                                              countDecimalPlaces(
                                                e.target.value
                                              ) > 2
                                            ) {
                                              tuter.nock = true
                                              tuter.altext = `一口价金额≤${minprt}（优惠力度至${record.miniZekouter * 100
                                                }折且优惠金额≥1）可精确到小数点后两位`
                                              // setPrtieDta()
                                              console.log(2)
                                              break
                                            }
                                            if (e.target.value * 1 == 0) {
                                              tuter.nock = true
                                              tuter.altext = `优惠后的价格须>0`
                                              // setPrtieDta()
                                              console.log(3)
                                              break
                                            }
                                            if (
                                              tuter.last_15_day_low_price &&
                                              e.target.value * 1 >
                                              tuter.last_15_day_low_price /
                                              100
                                            ) {
                                              tuter.nock = true
                                              tuter.altext = `需小与等于该SKU近15天最低价${(
                                                tuter.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              // setPrtieDta()
                                              console.log(4)
                                              break
                                            }

                                            tuter.nock = false
                                            tuter.altext = ""
                                            break
                                          case "1":
                                            tuter.zhijiangprt = e.target.value
                                            tuter.nowprit = (
                                              tuter.origin_price / 100 -
                                              e.target.value
                                            ).toFixed(2)
                                            // records.allconfig.pritNUmber = '¥' + tuter.nowprit
                                            outerNumprt.push(tuter.nowprit)
                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)
                                            const minprtmin: any = (
                                              (tuter.origin_price *
                                                (1 - record.miniZekouter)) /
                                              100
                                            ).toFixed(2)
                                            if (!e.target.value) {
                                              tuter.nock = true
                                              tuter.altext = `一口价不可为空`
                                              break
                                            }

                                            if (
                                              isNaN(tuter.nowprit * 1) ||
                                              tuter.nowprit < 0.01 ||
                                              tuter.nowprit * 1 > minprt * 1 ||
                                              countDecimalPlaces(
                                                tuter.nowprit
                                              ) > 2 ||
                                              e.target.value * 1 == 0
                                            ) {
                                              tuter.nock = true
                                              tuter.altext = `${minprtmin}≤直降金额<${(
                                                tuter.origin_price / 100
                                              ).toFixed(2)}（优惠力度至少${record.miniZekouter * 100
                                                }折且优惠金额≥${minprtmin}）可精确到小数点后两位`
                                              break
                                            }
                                            if (
                                              tuter.last_15_day_low_price &&
                                              tuter.nowprit * 1 >
                                              tuter.last_15_day_low_price /
                                              100
                                            ) {
                                              tuter.nock = true
                                              tuter.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                tuter.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              break
                                            }
                                            tuter.nock = false
                                            tuter.altext = ""
                                            break
                                          case "2":
                                            tuter.zhijiangprt = e.target.value
                                            tuter.nowprit = (
                                              Math.ceil(
                                                ~~(
                                                  (tuter.origin_price / 100) *
                                                  (e.target.value / 10) *
                                                  1000
                                                ) / 10
                                              ) / 100
                                            ).toFixed(2) //  (Math.ceil(~~(tuter.origin_price / 100 * e.target.value / 10 * 100)) / 100).toFixed(2)
                                            // records.allconfig.pritNUmber = '¥' + tuter.nowprit
                                            outerNumprt.push(tuter.nowprit)
                                            // console.log('一口价')
                                            // console.log('输入', e.target.value)
                                            // const minprtmin: any = (tuter.origin_price * 0.05 / 100).toFixed(2)
                                            if (!e.target.value) {
                                              tuter.nock = true
                                              tuter.altext = `打折不可为空`
                                              break
                                            }
                                            // console.log(isNaN((tuter.nowprit * 1)))
                                            // console.log((tuter.origin_price / 100 - tuter.nowprit) < 1 )
                                            // console.log((tuter.origin_price / 100 - tuter.nowprit) < 1 )
                                            // console.log(countDecimalPlaces(tuter.zhijiangprt) > 1)
                                            // console.log(tuter.zhijiangprt < 1 )
                                            // console.log((tuter.zhijiangprt > (record.miniZekouter * 10)))
                                            // console.log(tuter.zhijiangprt > (record.miniZekouter * 10))
                                            if (
                                              isNaN(tuter.nowprit * 1) ||
                                              tuter.origin_price / 100 -
                                              tuter.nowprit <
                                              1 ||
                                              countDecimalPlaces(
                                                tuter.zhijiangprt
                                              ) > 1 ||
                                              tuter.zhijiangprt < 1 ||
                                              tuter.zhijiangprt >
                                              record.miniZekouter * 10
                                            ) {
                                              // console.log('record.miniZekouter222', record.miniZekouter, record.miniZekouter * 10)
                                              // console.log(' tuter.zhijiangprt',  tuter.zhijiangprt)

                                              // if (isNaN((tuter.nowprit * 1)) || tuter.nowprit < 0.01 || (tuter.nowprit * 1 > minprt * 1) || countDecimalPlaces(tuter.nowprit) > 2 || e.target.value * 1 == 0) {
                                              tuter.nock = true
                                              tuter.altext = `打折范围：1.0~${record.miniZekouter * 10
                                                }折（优惠力度至少${record.miniZekouter * 100
                                                }折且优惠金额≥1）可精确到小数点后一位`
                                              break
                                            }
                                            if (
                                              tuter.last_15_day_low_price &&
                                              tuter.nowprit * 1 >
                                              tuter.last_15_day_low_price /
                                              100
                                            ) {
                                              tuter.nock = true
                                              tuter.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                tuter.last_15_day_low_price /
                                                100
                                              ).toFixed(2)}`
                                              break
                                            }
                                            tuter.nock = false
                                            tuter.altext = ""
                                            break
                                          default:
                                            break
                                        }
                                        if (tuter.nock) {
                                          records.allconfig.allErrstatus = true
                                          records.allconfig.allErrText =
                                            "部分SKU一口价填写错误，请展开查看"
                                        }

                                        records.allconfig.allPlteprt = "请输入"
                                      })
                                      if (outerNumprt && outerNumprt.length) {
                                        let getMiAxder = outerNumprt.sort(
                                          (a, b) => a - b
                                        )
                                        // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
                                        let mi = getMiAxder[0]
                                        let max =
                                          getMiAxder[getMiAxder.length - 1]
                                        if (mi == max) {
                                          records.allconfig.pritNUmber =
                                            "¥" + mi
                                        } else {
                                          records.allconfig.pritNUmber = `¥${mi}~¥${max}`
                                        }
                                      }
                                      setAddAllConfigData([...addAllConfigData])
                                    }}></Input>
                                </Form.Item>
                              </Form>
                            )
                          }
                        },
                        {
                          title: "活动库存",
                          key: "3",
                          align: "left",
                          render: (_, records: any, index: number) => {
                            if (!records.children) {
                              return (
                                <Form>
                                  <Form.Item
                                    extra={`当前库存: ${records.origin_stock}`}
                                    validateStatus={
                                      records.kuerr ? "error" : ""
                                    }
                                    className="errOncter">
                                    <Input
                                      notice={
                                        records.kuerr ? records.kuText : ""
                                      }
                                      noticeType={
                                        records.kuerr ? "error" : undefined
                                      }
                                      size="small"
                                      placeholder={
                                        record.business_code ==
                                          "OrdinaryTimeBuy"
                                          ? "无限制"
                                          : `≤${records.origin_stock}`
                                      }
                                      min={1}
                                      disabled={
                                        record.business_code ==
                                        "OrdinaryTimeBuy"
                                      }
                                      max={records.origin_stock}
                                      value={
                                        record.business_code ==
                                          "OrdinaryTimeBuy"
                                          ? ""
                                          : records.camp_stock_num
                                      }
                                      onChange={(e: any) => {
                                        // console.log('eee', e)
                                        records.camp_stock_num = e.target.value
                                        records.kuerr = false
                                        records.kuText = ""

                                        if (!e.target.value) {
                                          records.kuerr = true
                                          records.kuText = "活动库存不可为空"
                                          // return
                                        }
                                        if (
                                          isNaN(e.target.value * 1) ||
                                          countDecimalPlaces(e.target.value) >=
                                          1 ||
                                          e.target.value >
                                          records.origin_stock ||
                                          e.target.value <= 0
                                        ) {
                                          records.kuerr = true
                                          records.kuText = `请输入大于0且小于等于${records.origin_stock}的整数`
                                          // return
                                        }
                                        if (
                                          record.business_code ==
                                          "LimitQuantity" &&
                                          records.camp_stock_num > 1000
                                        ) {
                                          records.kuerr = true
                                          records.kuText =
                                            "限量抢购最大库存为1000"
                                        }
                                        const fingChengSkuList =
                                          record.selectActPrdlist.find(
                                            (itemsdrt) => {
                                              return (
                                                itemsdrt.product_id ==
                                                records.product_id
                                              )
                                            }
                                          )
                                        if (fingChengSkuList) {
                                          fingChengSkuList.allconfig.kuErr =
                                            false
                                          fingChengSkuList.allconfig.kuErrText =
                                            ""
                                          let skupriminandmax =
                                            fingChengSkuList.children
                                              .map((iter) => {
                                                if (iter.kuerr) {
                                                  fingChengSkuList.allconfig.kuErr =
                                                    true
                                                  fingChengSkuList.allconfig.kuErrText =
                                                    "部分SKU库存填写错误，请展开查看"
                                                }
                                                return isNaN(
                                                  iter.camp_stock_num * 1
                                                )
                                                  ? false
                                                  : iter.camp_stock_num || "0"
                                              })
                                              .sort((a, b) => a - b)
                                              .filter((biner) => biner)
                                          let mi = skupriminandmax[0]
                                          let max =
                                            skupriminandmax[
                                            skupriminandmax.length - 1
                                            ]
                                          console.log("mi", mi, max)
                                          if (mi == max) {
                                            if (mi == "0") {
                                              fingChengSkuList.allconfig.kuNum =
                                                ""
                                              fingChengSkuList.allconfig.kuTiyrt =
                                                "请输入"
                                            } else {
                                              fingChengSkuList.allconfig.kuNum =
                                                mi
                                              fingChengSkuList.allconfig.kuTiyrt =
                                                ""
                                            }
                                            // fingChengSkuList.allconfig.allPlterNum = mi
                                            // fingChengSkuList.allconfig.allPlteprt = ''
                                          } else {
                                            fingChengSkuList.allconfig.kuNum =
                                              ""
                                            fingChengSkuList.allconfig.kuTiyrt = `${mi}~${max}`
                                          }
                                          // fingChengSkuList
                                        }

                                        setAddAllConfigData([
                                          ...addAllConfigData
                                        ])
                                      }}></Input>
                                  </Form.Item>
                                </Form>
                              )
                            }

                            let minKu = records.children
                              .map((restrr) => restrr.origin_stock)
                              .sort((a, b) => a - b)[0]
                            return (
                              <Form>
                                <Form.Item
                                  extra={`当前最低sku库存: ${minKu}`}
                                  validateStatus={
                                    records.allconfig.kuErr ? "error" : ""
                                  }
                                  className="errOncter">
                                  <Input
                                    notice={
                                      records.allconfig.kuErr
                                        ? records.allconfig.kuErrText
                                        : ""
                                    }
                                    noticeType={
                                      records.allconfig.kuErr
                                        ? "error"
                                        : undefined
                                    }
                                    size="small"
                                    value={
                                      record.business_code == "OrdinaryTimeBuy"
                                        ? ""
                                        : records.allconfig.kuNum
                                    }
                                    placeholder={
                                      record.business_code == "OrdinaryTimeBuy"
                                        ? "无限制"
                                        : records.allconfig.kuTiyrt
                                    }
                                    disabled={
                                      record.business_code == "OrdinaryTimeBuy"
                                    }
                                    onChange={(e: any) => {
                                      records.allconfig.kuNum = e.target.value
                                      records.allconfig.kuErr = false
                                      records.allconfig.kuErrText = ""
                                      records.children.forEach((tuter) => {
                                        tuter.kuerr = false
                                        tuter.kuText = ""
                                        tuter.camp_stock_num = e.target.value
                                        if (!e.target.value) {
                                          tuter.kuerr = true
                                          tuter.kuText = "活动库存不可为空"
                                          // return
                                        }
                                        if (
                                          isNaN(e.target.value * 1) ||
                                          countDecimalPlaces(e.target.value) >=
                                          1 ||
                                          e.target.value > tuter.origin_stock ||
                                          e.target.value <= 0
                                        ) {
                                          tuter.kuerr = true
                                          tuter.kuText = `请输入大于0且小于等于${tuter.origin_stock}的整数`
                                          // return
                                        }
                                        if (
                                          record.business_code ==
                                          "LimitQuantity" &&
                                          tuter.camp_stock_num > 1000
                                        ) {
                                          tuter.kuerr = true
                                          tuter.kuText =
                                            "限量抢购最大库存为1000"
                                        }
                                        if (tuter.kuerr) {
                                          records.allconfig.kuErr = true
                                          records.allconfig.kuErrText =
                                            "部分SKU一口价填写错误，请展开查看"
                                        }
                                        records.allconfig.kuTiyrt = "请输入"
                                      })
                                      setAddAllConfigData([...addAllConfigData])
                                    }}></Input>
                                </Form.Item>
                              </Form>
                            )
                          }
                        },
                        {
                          title: "每人限领",
                          key: "4",
                          align: "left",
                          render: (_, records: any, index: number) => {
                            if (!records.children) {
                              return (
                                <Form>
                                  <Form.Item extra="">
                                    <Select
                                      size="small"
                                      value={records.user_limit * 1}
                                      style={{ width: 80 }}
                                      onChange={(e) => {
                                        records.user_limit = e
                                        const fingChengSkuList =
                                          record.selectActPrdlist.find(
                                            (itemsdrt) => {
                                              return (
                                                itemsdrt.product_id ==
                                                records.product_id
                                              )
                                            }
                                          )
                                        if (fingChengSkuList) {
                                          const Mihetr =
                                            fingChengSkuList.children
                                              .map((resyer) => {
                                                return resyer.user_limit
                                              })
                                              .sort((a, b) => a - b)
                                          const Minxs = Mihetr[0]
                                          const Maxxs =
                                            Mihetr[Mihetr.length - 1]
                                          console.log("Maxxs", Minxs, Maxxs)
                                          if (Minxs == Maxxs) {
                                            fingChengSkuList.allconfig.linNum =
                                              Minxs
                                            fingChengSkuList.allconfig.linTiyrt =
                                              ""
                                          } else {
                                            fingChengSkuList.allconfig.linNum =
                                              ""
                                            fingChengSkuList.allconfig.linTiyrt = `${Minxs} ~ ${Maxxs}`
                                          }
                                        }
                                        setAddAllConfigData([
                                          ...addAllConfigData
                                        ])
                                      }}>
                                      {linNumPx.map((lin, index) => {
                                        return (
                                          <Option value={lin.value} key={index}>
                                            {lin.label}
                                          </Option>
                                        )
                                      })}
                                    </Select>
                                  </Form.Item>
                                </Form>
                              )
                            }
                            return (
                              <Form>
                                <Form.Item extra="">
                                  <Select
                                    size="small"
                                    value={records.allconfig.linNum * 1 || ""}
                                    style={{ width: 80 }}
                                    placeholder={records.allconfig.linTiyrt}
                                    onChange={(e) => {
                                      records.allconfig.linNum = e
                                      records.children.forEach((ityter) => {
                                        ityter.user_limit = e
                                      })

                                      setAddAllConfigData([...addAllConfigData])
                                    }}>
                                    {linNumPx.map((lin, index) => {
                                      return (
                                        <Option value={lin.value} key={index}>
                                          {lin.label}
                                        </Option>
                                      )
                                    })}
                                  </Select>
                                </Form.Item>
                              </Form>
                            )
                          }
                        },
                        {
                          title: "操作",
                          key: "6",
                          align: "left",
                          ellipsis: true,
                          render: (_, records: any, index: number) => {
                            if (!records.children) {
                              return null
                            }
                            return (
                              <>
                                <Button
                                  type="link"
                                  style={{
                                    color: "#F11717"
                                  }}
                                  icon={<Icon type="DeleteIcon"></Icon>}
                                  onClick={() => {
                                    const copyLst: any[] = CircularJSON.parse(
                                      CircularJSON.stringify(
                                        record.selectActPrdlist
                                      )
                                    )
                                    let itemIndex = -1
                                    for (let i = 0; i < copyLst.length; i++) {
                                      if (
                                        copyLst[i].product_id ===
                                        records.product_id
                                      ) {
                                        itemIndex = i
                                        break
                                      }
                                    }
                                    // console.log('itemIndex', itemIndex)
                                    copyLst.splice(itemIndex, 1)
                                    record.selectActPrdlist = copyLst
                                    // addAllConfigData[record.index].selectActPrdlist = addSeopr
                                    if (showErrContent) {
                                      const letConter =
                                        record.selectActPrdlist.filter(
                                          (iter) => {
                                            return (
                                              iter.allconfig.kuErr ||
                                              iter.allconfig.allErrstatus
                                            )
                                          }
                                        )
                                      if (!letConter.length) {
                                        setshowErrContent(false)
                                      }
                                      return letConter
                                    }
                                    setAddAllConfigData([...addAllConfigData])
                                  }}>
                                  移除
                                </Button>
                              </>
                            )
                          }
                        }
                      ]}
                      dataSource={(() => {
                        if (record.globoSetConfig.sherchIds) {
                          return record.selectActPrdlist.filter((iter) => {
                            return (
                              iter.product_id == record.globoSetConfig.sherchIds
                            )
                          })
                        }
                        if (showErrContent) {
                          const letConter = record.selectActPrdlist.filter(
                            (iter) => {
                              return (
                                iter.allconfig.kuErr ||
                                iter.allconfig.allErrstatus
                              )
                            }
                          )
                          // if(!letConter.length) {
                          //     setshowErrContent(false)

                          // }
                          return letConter
                        }
                        return record.selectActPrdlist
                      })()}
                      style={{
                        width: "100%"
                        // height: 710
                      }}
                      // scroll={{ y: 545 }}
                      pagination={{
                        pageSize: record.pageSize,
                        // current: shearData.page + 1,
                        pageSizeOptions: ["10", "20", "50", "100", "200"],
                        total: record.selectActPrdlist.length,
                        // onShowSizeChange: (pageSize) => {
                        //     console.log('pageSize', pageSize)
                        // },
                        onChange: (page, pageSize: any) => {
                          record.pageSize = pageSize
                          record.page = page
                          setAddAllConfigData([...addAllConfigData])
                          // setPageSize(pageSize)
                          // console.log('修改页', page, pageSize)
                          // shearData.page = page - 1
                          // shearData.pageSize = pageSize
                          // setShearData({ ...shearData })
                          // getProdectListFunAs(shearData)
                        },
                        style: {
                          marginTop: 20
                        },
                        showTotal: (total, range) => {
                          return `已添加 ${total} 商品`
                        }
                      }}
                      rowKey={(record: any, index) => {
                        if (record.children) {
                          return record.product_id
                        }
                        return record.sku_id
                      }}
                      title={(data) => {
                        // console.log('data', data)
                        // 返回数据列表
                        // if (data.children) {

                        // }
                        let conterkey = false
                        // 这里需要现在使用
                        if (!chengeSopterkey) {
                          if (
                            record.selectConfigIndex !== -1 &&
                            configDataUse[record.selectConfigIndex]
                          ) {
                            conterkey = true
                            record.sku_prd_config =
                              configDataUse[record.selectConfigIndex]
                          }
                          record.globoSetConfig.pritType =
                            record.sku_prd_config?.pritType ||
                            record.globoSetConfig.pritType
                        }

                        return (
                          <Space
                            align="center"
                            style={{
                              width: "100%",
                              justifyContent: "space-between"
                            }}>
                            <Space align="center">
                              <Input.Group compact>
                                <Tooltip
                                  title={
                                    conterkey
                                      ? "已添加sku价格配置无法修改, 请到下方sku几个配置中编辑"
                                      : ""
                                  }>
                                  <Select
                                    size="small"
                                    disabled={conterkey}
                                    value={
                                      record.globoSetConfig.pritType === "3"
                                        ? "2"
                                        : record.globoSetConfig.pritType
                                    }
                                    defaultValue="0"
                                    style={{ width: 85 }}
                                    onChange={(e) => {
                                      record.globoSetConfig.pritType = e
                                      setAddAllConfigData([...addAllConfigData])
                                      chengeSopterkey = true
                                      setTimeout(() => {
                                        chengeSopterkey = false
                                      }, 1000)
                                    }}>
                                    <Option value="0">一口价</Option>
                                    <Option value="1">直降</Option>
                                    <Option value="2">打折</Option>
                                  </Select>
                                </Tooltip>
                                <Input
                                  placeholder={`请输入${record.globoSetConfig.pritType === "0"
                                    ? "一口价"
                                    : record.globoSetConfig.pritType === "1"
                                      ? "直减金额"
                                      : "折扣"
                                    }`}
                                  size="small"
                                  style={{
                                    width: 90
                                  }}
                                  suffix={
                                    record.globoSetConfig.pritType === "0" ||
                                      record.globoSetConfig.pritType === "1"
                                      ? "元"
                                      : "折"
                                  }
                                  value={
                                    record.globoSetConfig[
                                    `pritort${record.globoSetConfig.pritType}`
                                    ]
                                  }
                                  onChange={(e: any) => {
                                    record.globoSetConfig[
                                      `pritort${record.globoSetConfig.pritType}`
                                    ] = e.target.value
                                    setAddAllConfigData([...addAllConfigData])
                                  }}></Input>
                              </Input.Group>
                              <Input.Group compact>
                                <Select
                                  size="small"
                                  disabled={
                                    record.business_code === "OrdinaryTimeBuy"
                                  }
                                  value={record.globoSetConfig.kuType}
                                  style={{ width: 140 }}
                                  onChange={(e: any) => {
                                    record.globoSetConfig.kuType = e
                                    setAddAllConfigData([...addAllConfigData])
                                  }}>
                                  <Option value="0">活动库存(按数量)</Option>
                                  <Option value="1">活动库存(按比例)</Option>
                                </Select>
                                <Input
                                  size="small"
                                  disabled={
                                    record.business_code === "OrdinaryTimeBuy"
                                  }
                                  placeholder={
                                    record.globoSetConfig.kuType === "0"
                                      ? "请输入数字"
                                      : "1-100的整数"
                                  }
                                  wrapperStyle={{ width: 80 }}
                                  value={
                                    record.globoSetConfig[
                                    `ku${record.globoSetConfig.kuType}`
                                    ]
                                  }
                                  suffix={
                                    record.globoSetConfig.kuType === "0"
                                      ? ""
                                      : "%"
                                  }
                                  onChange={(e) => {
                                    record.globoSetConfig[
                                      `ku${record.globoSetConfig.kuType}`
                                    ] = e.target.value
                                    setAddAllConfigData([...addAllConfigData])
                                  }}
                                />
                              </Input.Group>
                              <Input.Group compact>
                                <span
                                  style={{
                                    width: 80,
                                    height: "28px",
                                    border: "1px solid #DCDEE1",
                                    fontSize: "12px",
                                    lineHeight: "26px",
                                    textAlign: "center",
                                    display: "inline-block",
                                    color: "#000"
                                  }}>
                                  每人限购
                                </span>
                                <Select
                                  size="small"
                                  value={record.globoSetConfig.xiangg}
                                  style={{ width: 80 }}
                                  placeholder="请选择"
                                  onChange={(e) => {
                                    record.globoSetConfig.xiangg = e
                                    setAddAllConfigData([...addAllConfigData])
                                  }}>
                                  {linNumPx.map((lin, index) => {
                                    return (
                                      <Option value={lin.value} key={index}>
                                        {lin.label}
                                      </Option>
                                    )
                                  })}
                                </Select>
                              </Input.Group>
                              <Button
                                type="dashed"
                                size="small"
                                onClick={(e: any) => {
                                  // console.log('12345', record, record.globoSetConfig, record.selectActPrdlist)
                                  if (
                                    !record.selectChengeShopItems ||
                                    !record.selectChengeShopItems.length
                                  ) {
                                    message.warning("请勾选要设置的商品")
                                    return
                                  }
                                  record.upConfug.pritType =
                                    record.globoSetConfig.pritType

                                  // 判断填入项目
                                  record.selectChengeShopItems
                                    .map((itemter) => {
                                      return record.selectActPrdlist.find(
                                        (rester) =>
                                          rester.product_id === itemter
                                      )
                                    })
                                    .forEach((setItem) => {
                                      if (!setItem) return
                                      // 限领
                                      if (record.globoSetConfig.xiangg) {
                                        setItem.allconfig.linNum =
                                          record.globoSetConfig.xiangg
                                        setItem.children.forEach((iyters) => {
                                          iyters.user_limit =
                                            record.globoSetConfig.xiangg
                                        })
                                      }
                                      // 库存
                                      if (
                                        record.globoSetConfig[
                                        `ku${record.globoSetConfig.kuType}`
                                        ]
                                      ) {
                                        setItem.allconfig.kuNum = ""

                                        if (
                                          record.globoSetConfig.kuType == "0"
                                        ) {
                                          setItem.allconfig.kuNum =
                                            record.globoSetConfig[
                                            `ku${record.globoSetConfig.kuType}`
                                            ]
                                          setItem.children.forEach((iyters) => {
                                            iyters.camp_stock_num =
                                              record.globoSetConfig[
                                              `ku${record.globoSetConfig.kuType}`
                                              ]
                                          })
                                        }
                                        if (
                                          record.globoSetConfig.kuType == "1"
                                        ) {
                                          const ouyer: any = []
                                          setItem.children.forEach((iyters) => {
                                            iyters.camp_stock_num = (
                                              iyters.origin_stock *
                                              (record.globoSetConfig[
                                                `ku${record.globoSetConfig.kuType}`
                                              ] /
                                                100)
                                            ).toFixed(0)
                                            ouyer.push(iyters.camp_stock_num)
                                          })
                                          const mimax = ouyer.sort(
                                            (a, b) => a - b
                                          )
                                          const minc = mimax[0]
                                          const maxc = mimax[mimax.length - 1]
                                          if (minc == maxc) {
                                            setItem.allconfig.kuNum = minc
                                          } else {
                                            setItem.allconfig.kuTiyrt = `${minc}~${maxc}`
                                          }
                                        }
                                      }

                                      if (
                                        record.globoSetConfig[
                                        `pritort${record.globoSetConfig.pritType}`
                                        ]
                                      ) {
                                        if (
                                          record.globoSetConfig.pritType == "0"
                                        ) {
                                          setItem.allconfig.allPlterNum =
                                            record.globoSetConfig[
                                            `pritort${record.globoSetConfig.pritType}`
                                            ]
                                          setItem.children.forEach((tres) => {
                                            tres.nowprit =
                                              record.globoSetConfig[
                                              `pritort${record.globoSetConfig.pritType}`
                                              ]
                                          })
                                        }
                                        if (
                                          record.globoSetConfig.pritType == "1"
                                        ) {
                                          setItem.allconfig.allPlterNum =
                                            record.globoSetConfig[
                                            `pritort${record.globoSetConfig.pritType}`
                                            ]
                                          setItem.children.forEach((tres) => {
                                            tres.zhijiangprt =
                                              record.globoSetConfig[
                                              `pritort${record.globoSetConfig.pritType}`
                                              ]
                                            tres.nowprit = (
                                              tres.origin_price / 100 -
                                              tres.zhijiangprt
                                            ).toFixed(2)
                                          })
                                        }
                                        if (
                                          record.globoSetConfig.pritType == "2"
                                        ) {
                                          setItem.allconfig.allPlterNum =
                                            record.globoSetConfig[
                                            `pritort${record.globoSetConfig.pritType}`
                                            ]
                                          setItem.children.forEach((tres) => {
                                            tres.zhijiangprt =
                                              record.globoSetConfig[
                                              `pritort${record.globoSetConfig.pritType}`
                                              ]
                                            tres.nowprit = (
                                              ((tres.origin_price / 100) *
                                                tres.zhijiangprt) /
                                              10
                                            ).toFixed(2)
                                          })
                                        }
                                      }
                                      // if(record.globoSetConfig.kuType == '0' && )
                                      // setItem.
                                    })
                                  record.globoSetConfig[
                                    `ku${record.globoSetConfig.kuType}`
                                  ] = ""
                                  record.globoSetConfig.xiangg = ""
                                  record.globoSetConfig[
                                    `pritort${record.globoSetConfig.pritType}`
                                  ] = ""
                                  record.selectChengeShopItems = []

                                  record.selectActPrdlist.forEach(
                                    (cheackAllDatas) => {
                                      // console.log('开始检测全部项', cheackAllDatas)
                                      cheackAllDatas.children.forEach(
                                        (records) => {
                                          let orderpirs: any = (
                                            ~~(
                                              records.origin_price *
                                              record.miniZekouter
                                            ) / 100
                                          ).toFixed(2)
                                          const minprt: any =
                                            orderpirs * 100 -
                                              records.origin_price >=
                                              100
                                              ? orderpirs
                                              : (
                                                ~~(
                                                  records.origin_price - 100
                                                ) / 100
                                              ).toFixed(2)
                                          // const minprt: any = (~~(records.origin_price * record.miniZekouter) / 100).toFixed(2)

                                          switch (record.upConfug.pritType) {
                                            case "0":
                                              // console.log('一口价')
                                              // console.log('输入', e.target.value)
                                              if (!records.nowprit) {
                                                records.nock = true
                                                records.altext = `一口价不可为空`
                                                // setPrtieDta()
                                                // console.log(1)
                                                break
                                              }
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.nowprit * 1 >
                                                minprt * 1 ||
                                                countDecimalPlaces(
                                                  records.nowprit
                                                ) > 2
                                              ) {
                                                records.nock = true
                                                records.altext = `一口价金额≤${minprt}（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥1）可精确到小数点后两位`
                                                // setPrtieDta()
                                                // console.log(2)
                                                break
                                              }
                                              if (records.nowprit * 1 == 0) {
                                                records.nock = true
                                                records.altext = `优惠后的价格须>0`
                                                // setPrtieDta()
                                                // console.log(3)
                                                break
                                              }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                // console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break
                                            case "1":
                                              // console.log('一口价')
                                              // console.log('输入', e.target.value)
                                              // const minprt: any = (records.origin_price * 0.95 / 100).toFixed(2)
                                              const minprtmin: any = (
                                                (records.origin_price *
                                                  (1 - record.miniZekouter)) /
                                                100
                                              ).toFixed(2)
                                              if (!records.zhijiangprt) {
                                                records.nock = true
                                                records.altext = `直降不可为空`
                                                // setPrtieDta()
                                                // console.log(1)
                                                break
                                              }
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.nowprit < 0.01 ||
                                                records.nowprit * 1 >
                                                minprt * 1 ||
                                                countDecimalPlaces(
                                                  records.zhijiangprt
                                                ) > 2 ||
                                                e.target.value * 1 == 0
                                              ) {
                                                records.nock = true
                                                records.altext = `${minprtmin}≤直降金额<${(
                                                  records.origin_price / 100
                                                ).toFixed(2)}（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥${minprtmin}）可精确到小数点后两位`
                                                // records.altext = `一口价金额≤${minprt}（优惠力度至少95折且优惠金额≥1）可精确到小数点后两位`
                                                // setPrtieDta()
                                                // console.log(2)
                                                break
                                              }
                                              // if (records.nowprit * 1 == 0) {
                                              //     records.nock = true
                                              //     records.altext = `优惠后的价格须>0`
                                              //     // setPrtieDta()
                                              //     console.log(3)
                                              //     break
                                              // }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break

                                            case "2":
                                              // console.log('一口价')
                                              // console.log('输入', e.target.value)
                                              // const minprt: any = (records.origin_price * 0.95 / 100).toFixed(2)
                                              if (!records.zhijiangprt) {
                                                records.nock = true
                                                records.altext = `打折不可为空`
                                                // setPrtieDta()
                                                // console.log(1)
                                                break
                                              }
                                              if (
                                                isNaN(records.nowprit * 1) ||
                                                records.origin_price / 100 -
                                                records.nowprit <
                                                1 ||
                                                countDecimalPlaces(
                                                  records.zhijiangprt
                                                ) > 1 ||
                                                records.zhijiangprt < 1 ||
                                                records.zhijiangprt >
                                                record.miniZekouter * 10
                                              ) {
                                                // if (isNaN((records.nowprit * 1)) || records.nowprit < 0.01 || (records.nowprit * 1 > minprt * 1) || countDecimalPlaces(records.nowprit) > 2 || records.zhijiangprt * 1 == 0) {

                                                // if (isNaN((records.nowprit * 1)) || (records.nowprit * 1 > minprt * 1) || countDecimalPlaces(records.nowprit) > 2) {
                                                records.nock = true
                                                records.altext = `打折范围：1.0~${record.miniZekouter * 10
                                                  }折（优惠力度至少${record.miniZekouter * 100
                                                  }折且优惠金额≥1）可精确到小数点后一位`
                                                // setPrtieDta()
                                                // console.log(2)
                                                break
                                              }
                                              // if (records.nowprit * 1 == 0) {
                                              //     records.nock = true
                                              //     records.altext = `优惠后的价格须>0`
                                              //     // setPrtieDta()
                                              //     console.log(3)
                                              //     break
                                              // }
                                              if (
                                                records.last_15_day_low_price &&
                                                records.nowprit * 1 >
                                                records.last_15_day_low_price /
                                                100
                                              ) {
                                                records.nock = true
                                                records.altext = `优惠后需小与等于该SKU近15天最低价${(
                                                  records.last_15_day_low_price /
                                                  100
                                                ).toFixed(2)}`
                                                // setPrtieDta()
                                                console.log(4)
                                                break
                                              }
                                              records.nock = false
                                              records.altext = ""
                                              break
                                            default:
                                              break
                                          }
                                          // console.log('判断情况', record, records, index)
                                          const fingChengSkuList =
                                            record.selectActPrdlist.find(
                                              (itemsdrt) => {
                                                return (
                                                  itemsdrt.product_id ==
                                                  records.product_id
                                                )
                                              }
                                            )
                                          let outerNumprt: any = []
                                          if (fingChengSkuList) {
                                            /**
                                             * 价格
                                             */
                                            fingChengSkuList.allconfig.allErrstatus =
                                              false
                                            fingChengSkuList.allconfig.allErrText =
                                              ""
                                            let skupriminandmax =
                                              fingChengSkuList.children
                                                .map((iter) => {
                                                  if (iter.nock) {
                                                    fingChengSkuList.allconfig.allErrstatus =
                                                      true
                                                    fingChengSkuList.allconfig.allErrText =
                                                      "部分SKU一口价填写错误，请展开查看"
                                                  }
                                                  outerNumprt.push(
                                                    isNaN(iter.nowprit * 1)
                                                      ? false
                                                      : iter.nowprit || "0"
                                                  )
                                                  // return isNaN(iter.nowprit * 1) ? false : (iter.nowprit || '0')
                                                  if (
                                                    record.upConfug.pritType ==
                                                    "0"
                                                  ) {
                                                    return isNaN(
                                                      iter.nowprit * 1
                                                    )
                                                      ? false
                                                      : iter.nowprit || "0"
                                                  }
                                                  if (
                                                    record.upConfug.pritType ==
                                                    "1" ||
                                                    record.upConfug.pritType ==
                                                    "2"
                                                  ) {
                                                    return isNaN(
                                                      iter.zhijiangprt * 1
                                                    )
                                                      ? false
                                                      : iter.zhijiangprt || "0"
                                                  }
                                                })
                                                .sort((a, b) => a - b)
                                                .filter((biner) => biner)

                                            if (
                                              outerNumprt &&
                                              outerNumprt.length
                                            ) {
                                              let getMiAxder = outerNumprt.sort(
                                                (a, b) => a - b
                                              )
                                              // console.log('getMiAx[0]', getMiAx[0], getMiAx[getMiAx.length - 1])
                                              let mi = getMiAxder[0]
                                              let max =
                                                getMiAxder[
                                                getMiAxder.length - 1
                                                ]
                                              if (mi == max) {
                                                fingChengSkuList.allconfig.pritNUmber =
                                                  "¥" + mi
                                              } else {
                                                fingChengSkuList.allconfig.pritNUmber = `¥${mi}~¥${max}`
                                              }
                                            }

                                            let mi = skupriminandmax[0]
                                            let max =
                                              skupriminandmax[
                                              skupriminandmax.length - 1
                                              ]
                                            if (mi == max) {
                                              if (mi == "0") {
                                                fingChengSkuList.allconfig.allPlterNum =
                                                  ""
                                                fingChengSkuList.allconfig.allPlteprt =
                                                  "请输入"
                                              } else {
                                                fingChengSkuList.allconfig.allPlterNum =
                                                  mi
                                                fingChengSkuList.allconfig.allPlteprt =
                                                  ""
                                              }
                                              // fingChengSkuList.allconfig.allPlterNum = mi
                                              // fingChengSkuList.allconfig.allPlteprt = ''
                                            } else {
                                              fingChengSkuList.allconfig.allPlterNum =
                                                ""
                                              fingChengSkuList.allconfig.allPlteprt = `${mi}~${max}`
                                            }
                                            /**
                                             * 库存
                                             */
                                            const Mihetr =
                                              fingChengSkuList.children
                                                .map((resyer) => {
                                                  return resyer.camp_stock_num
                                                })
                                                .sort((a, b) => a - b)
                                            const Minxs = Mihetr[0]
                                            const Maxxs =
                                              Mihetr[Mihetr.length - 1]
                                            console.log("Maxxs", Minxs, Maxxs)
                                            if (Minxs == Maxxs) {
                                              fingChengSkuList.allconfig.kuNum =
                                                Minxs
                                              fingChengSkuList.allconfig.kuTiyrt =
                                                ""
                                            } else {
                                              fingChengSkuList.allconfig.kuNum =
                                                ""
                                              fingChengSkuList.allconfig.kuTiyrt = `${Minxs} ~ ${Maxxs}`
                                            }
                                          }
                                        }
                                      )
                                    }
                                  )
                                  // console.log('record.globoSetConfig.kuType', record.globoSetConfig.pritType)
                                  setAddAllConfigData([...addAllConfigData])

                                  // 最后做检测
                                  //更新数据
                                }}>
                                批量填充
                              </Button>
                              {!!record.errSkulen && (
                                <Space size={4}>
                                  <Tag type="error">
                                    有{record.errSkulen}个错误
                                  </Tag>
                                  <Button
                                    size="mini"
                                    type="link"
                                    onClick={() => {
                                      // console.log('显示错误的项 ')
                                      setshowErrContent(!showErrContent)
                                      // fomaterData(true)
                                    }}>
                                    {showErrContent ? "显示全部" : "显示错误项"}
                                  </Button>
                                  <Button
                                    size="mini"
                                    type="primary"
                                    onClick={() => {
                                      // console.log('设置最低能够适配的价格')
                                      setshowErrContent(false)
                                      fomaterData(record.indexkey)
                                    }}>
                                    自动适配
                                  </Button>
                                </Space>
                              )}
                            </Space>
                            <Space align="center">
                              <Space align="center" size={4}>
                                <Switch
                                  size="small"
                                  checked={
                                    record.globoSetConfig.defaultExpandAllRows
                                  }
                                  onChange={(e) => {
                                    record.globoSetConfig.defaultExpandAllRows =
                                      e
                                    if (e) {
                                      record.globoSetConfig.defaultExpandedRowKeys =
                                        record.selectActPrdlist.map(
                                          (iyter) => iyter.product_id
                                        )
                                    } else {
                                      record.globoSetConfig.defaultExpandedRowKeys =
                                        []
                                    }
                                    // console.log('record.globoSetConfig.defaultExpandedRowKeys', record.globoSetConfig.defaultExpandedRowKeys)
                                    setAddAllConfigData([...addAllConfigData])
                                  }}
                                />
                                {record.globoSetConfig.defaultExpandAllRows
                                  ? "收起"
                                  : "展开"}
                                sku
                              </Space>
                              <Search
                                placeholder="输入商品ID"
                                size="small"
                                // onChange={(e) => {
                                //     if (!e.target.value) {
                                //         record.globoSetConfig.sherchIds = ''
                                //         setAddAllConfigData([...addAllConfigData])
                                //     }
                                // }}
                                style={{
                                  width: 120
                                }}
                                allowClear
                                onSearch={(e) => {
                                  // console.log('ee', e)
                                  record.globoSetConfig.sherchIds = e
                                  if (e) {
                                    const getItems =
                                      record.selectActPrdlist.filter((iter) => {
                                        return (
                                          iter.product_id ==
                                          record.globoSetConfig.sherchIds
                                        )
                                      })
                                    if (!getItems || !getItems.length) {
                                      message.error("无符合筛选条件商品")
                                      return
                                    }
                                    setShowGoodsStatus(false)
                                  }

                                  setAddAllConfigData([...addAllConfigData])
                                }}
                              />
                            </Space>
                          </Space>
                        )
                      }}
                      rowSelection={{
                        checkStrictly: false,
                        selectedRowKeys: record.selectChengeShopItems,
                        onChange: (e) => {
                          record.selectChengeShopItems = e
                          setAddAllConfigData([...addAllConfigData])
                          // console.log('修改选择回调', e)
                        },
                        renderCell: (checked, record, index, originNode) => {
                          // console.log('record', record)
                          if (!record.children) {
                            return null
                          }
                          // console.log('checked', checked)
                          return originNode
                        },
                        getCheckboxProps: (record) => ({
                          disabled: !record.children // Column configuration not to be checked
                          // name: record.name,
                        })
                      }}
                      expandable={{
                        indentSize: 1,
                        // defaultExpandAllRows: record.globoSetConfig.defaultExpandAllRows,
                        expandedRowKeys:
                          record.globoSetConfig.defaultExpandedRowKeys,
                        expandedRowClassName: (record, index) => {
                          return "expandable-sub-table"
                          // return index === 1 ? 'expandable-sub-table' : '';
                        },
                        onExpand: (expanded, records) => {
                          if (expanded) {
                            record.globoSetConfig.defaultExpandedRowKeys.push(
                              records.product_id
                            )
                          } else {
                            record.globoSetConfig.defaultExpandedRowKeys.splice(
                              record.globoSetConfig.defaultExpandedRowKeys.indexOf(
                                records.product_id
                              ),
                              1
                            )
                          }
                          // console.log('点击展开', expanded, records, record)
                          setAddAllConfigData([...addAllConfigData])
                        }
                        // expandIcon: ({ expanded, onExpand, record }) => {
                        //     if (!record.children) {
                        //         return null;
                        //     }
                        //     return expanded ? (
                        //         <div className="cpmyer">
                        //             <Icon.OpenIcon onClick={e => onExpand(record, e)} />
                        //         </div>
                        //     ) : (
                        //         <div className="cpmyer">
                        //             <Icon.PutAwayIcon onClick={e => onExpand(record, e)} />
                        //         </div>
                        //     );
                        // },
                      }}></Table>
                  </div>
                )
              }
              // defaultExpandedRowKeys:
            }}></Table>
        </Space>
      </Spin>
      {/* 编辑添加活动 */}
      <Modal
        title={
          <>
            {editLtalpStatus.status ? (
              "编辑活动"
            ) : (
              <div className="showStaterTot">
                添加活动 (已添加 {activetConfigInfoList.length} 个活动)
                <Button
                  type="link"
                  size="mini"
                  icon={
                    <Icon
                      type={
                        hidenAll ? "DirectionUpIcon" : "DirectionDownIcon"
                      }></Icon>
                  }
                  onClick={() => {
                    setHidenAll(!hidenAll)
                    activetConfigInfoList.forEach((item) => {
                      item.showAll = !hidenAll
                    })
                    setActivetConfigInfoList([...activetConfigInfoList])
                  }}>
                  {hidenAll ? "收起" : "展开"}全部
                </Button>
              </div>
            )}
          </>
        }
        visible={showAddContent}
        width={1050}
        bodyBottomMask
        wrapClassName={"add-content-modal"}
        onCancel={() => {
          setShowAddContent(false)
        }}
        footer={
          <div
            className="bote"
            style={{
              display: "flex",
              justifyContent: "space-between"
            }}>
            <div className="leter">
              {!editLtalpStatus.status && false && (
                <Popover
                  content={
                    <Space direction="vertical">
                      <div>这里可以添加多个活动</div>
                      <div
                        className="moter"
                        style={{
                          width: "100%",
                          display: "flex",
                          justifyContent: "flex-end"
                        }}>
                        {/* <Button size="mini" type="primary" onClick={() => {
                                                setShowAddCouponStuats(false)
                                            }}>知道了</Button> */}
                      </div>
                    </Space>
                  }
                // visible={showAddCouponStuats}
                >
                  <Button
                    size="mini"
                    onClick={() => {
                      activetConfigInfoList.push(
                        configFarMate(activetConfiginfo)
                      )
                      setActivetConfigInfoList([...activetConfigInfoList])
                    }}
                    icon={<Icon type="AddIcon"></Icon>}>
                    新增活动
                  </Button>
                </Popover>
              )}
            </div>
            <div className="rngdtrr">
              <Space>
                <Button
                  type="primary"
                  size="mini"
                  onClick={() => {
                    // 检查添加项
                    let openPush: any = []
                    // const adds = activetConfigInfoList.map((item, index) => {

                    //     item.indexkey = index + item.begin_time
                    //     openPush.push(item.indexkey)
                    //     return item
                    // })
                    if (editLtalpStatus.status) {
                      // addAllConfigData[editLtalpStatus.index] = activetConfigInfoList[0]
                      addAllConfigData[editLtalpStatus.index] =
                        CircularJSON.parse(
                          CircularJSON.stringify(activetConfigInfoList)
                        )[0]
                    } else {
                      // addAllConfigData.push(...activetConfigInfoList)
                      addAllConfigData.push(
                        ...CircularJSON.parse(
                          CircularJSON.stringify(activetConfigInfoList)
                        )
                      )
                    }
                    // const adds = CircularJSON.parse(CircularJSON.stringify(activetConfigInfoList)).map((item, index) => {

                    //     item.indexkey = index + item.begin_time
                    //     openPush.push(item.indexkey)
                    //     return item
                    // })
                    for (let i = 0; i < addAllConfigData.length; i++) {
                      if (!addAllConfigData[i].indexkey) {
                        addAllConfigData[i].indexkey =
                          i + addAllConfigData[i].begin_time
                        openPush.push(addAllConfigData[i].indexkey)
                      } else {
                        addAllConfigData[i].indexkey =
                          i + addAllConfigData[i].begin_time
                      }
                    }
                    // addAllConfigData.forEach((item, index) => {
                    //     console.log('item', item, index)
                    //     item.indexkey = index + item.begin_time
                    //     // return item
                    // })
                    // console.log('addAllConfigData', addAllConfigData)
                    setactOpenKeys([...openPush])
                    // console.log('adds', adds)
                    setAddAllConfigData([...addAllConfigData])
                    setShowAddContent(false)
                    if (!getGoodsPredect || !getGoodsPredect.length) {
                      return Modal.warning({
                        title: "提示",
                        content: "请先获取商品列表",
                        okText: "获取商品",
                        onOk: () => {
                          if (editLtalpStatus.status) {
                            getActPrdDataList(
                              addAllConfigData[editLtalpStatus.index]
                            )
                          } else {
                            getActPrdDataList(
                              addAllConfigData[addAllConfigData.length - 1]
                            )
                          }
                        }
                      })
                    }
                    setLodinDataStatus(true)
                    checkPromotionValidationFun(addAllConfigData).then(
                      (res) => {
                        setLodinDataStatus(false)
                        if (editLtalpStatus.status) {
                          getChackDataList(
                            addAllConfigData[editLtalpStatus.index],
                            res
                          )
                        } else {
                          getChackDataList(
                            addAllConfigData[addAllConfigData.length - 1],
                            res
                          )
                        }
                        // getChackDataList(addAllConfigData[interAdd], res)
                      }
                    )
                  }}>
                  {!editLtalpStatus.status ? "添加" : "保存"}
                </Button>
                <Button
                  size="mini"
                  onClick={() => {
                    setShowAddContent(false)
                  }}>
                  取消
                </Button>
              </Space>
            </div>
          </div>
        }>
        {...activetConfigInfoList.map((item, index) => {
          // if (editLtalpStatus.status && editLtalpStatus.index != index) {
          //     return null
          // }
          return (
            <AddItemMt
              activetConfiginfo={item}
              key={index}
              indexItem={index}
              editLtalpStatus={editLtalpStatus}
              onChangeItem={(e) => {
                activetConfigInfoList[0] = e
                setActivetConfigInfoList([...activetConfigInfoList])
              }}
              onDeleteImageItem={() => {
                if (activetConfigInfoList.length <= 1) {
                  message.error("至少保留一个活动")
                  return
                }
                activetConfigInfoList.splice(index, 1)
                setActivetConfigInfoList([...activetConfigInfoList])
              }}></AddItemMt>
          )
        })}
      </Modal>

      <Modal
        title={
          <>
            选择活动商品
            <span>
              {" "}
              已选择:{" "}
              {
                getSelectGoodsPredects.filter((item) => item.selectStatus)
                  .length
              }{" "}
            </span>
          </>
        }
        visible={showselectActPrd}
        width={998}
        bodyBottomMask
        wrapClassName={"add-content-modal"}
        onCancel={() => setShowselectActPrd(false)}
        // onOk={() => setShowselectActPrd(false)}
        footer={
          <div
            className="bote"
            style={{
              display: "flex",
              justifyContent: "space-between"
            }}>
            <div className="leter">
              <Pagination
                pageSizeOptions={["10", "20", "50"]}
                defaultCurrent={pageContent.page}
                defaultPageSize={pageContent.size}
                total={getSelectGoodsPredects.length}
                showQuickJumper
                showSizeChanger
                showTotal={(total) => `共${total}条`}
                onChange={(e, ps: any) => {
                  // console.log('e', e, ps)
                  pageContent.page = e
                  pageContent.size = ps
                  setPageContent({ ...pageContent })
                }}
              />
            </div>
            <div className="rngdtrr">
              <Space>
                <Button
                  type="primary"
                  size="mini"
                  onClick={() => {
                    // 这里确定活动信息
                    let indexa = -1
                    const gettabItem = addAllConfigData.find(
                      (itemsnerr, index) => {
                        if (
                          selectActPrdItemKey ===
                          `${itemsnerr.indexkey}${itemsnerr.begin_time}${itemsnerr.end_time}`
                        ) {
                          indexa = index
                          return true
                        }
                        return false
                      }
                    )

                    if (
                      gettabItem.selectConfigIndex !== -1 &&
                      configDataUse[gettabItem.selectConfigIndex]
                    ) {
                      gettabItem.sku_prd_config =
                        configDataUse[gettabItem.selectConfigIndex]
                    }

                    gettabItem.selectActPrdlist = getSelectGoodsPredects
                      .filter((item) => item.selectStatus)
                      .map((resa) => {
                        resa.children = []
                        resa.allconfig = {
                          allPlterNum: "",
                          allPlteprt: "",
                          allErrstatus: false,
                          allErrText: "",

                          pritNUmber: "", //降价后的价格范围

                          kuErr: false,
                          kuErrText: "",
                          kuTiyrt: "",
                          kuNum: "",

                          linNum: 1,
                          linTiyrt: ""
                        }

                        resa.index = indexa
                        return resa
                      })
                    // setAddAllConfigData([...addAllConfigData])
                    // 已经添加配置的情况下可以生成创建配置

                    console.log('gettabItem.selectActPrdlist', gettabItem.selectActPrdlist)

                    setShowGoodsStatus(false)

                    getPrdListSkus(gettabItem.indexkey)

                    setShowselectActPrd(false)
                  }}>
                  确认
                </Button>
                <Button
                  size="mini"
                  onClick={() => {
                    setShowselectActPrd(false)
                  }}>
                  取消
                </Button>
              </Space>
            </div>
          </div>
        }
      // destroyOnClose
      >
        {/* {JSON.stringify(getSelectGoodsPredects)} */}
        <Space direction="vertical">
          <Form layout="inline">
            <Form.Item label="商品ID" name="goods_name">
              <Input
                placeholder="请输入商品ID,可多个，使用逗号、空格分隔"
                style={{
                  width: 300
                }}
                size="small"
                value={shearProdectConfig.ids}
                onChange={(e) => {
                  shearProdectConfig.ids = e.target.value
                }}
              />
            </Form.Item>
            <Form.Item noStyle>
              <Space>
                <Button
                  type="primary"
                  size="small"
                  onClick={() => {
                    // console.log('shearProdectConfig', shearProdectConfig)
                    setShearProdectConfig({ ...shearProdectConfig })
                    setPageContent({ ...pageContent, page: 1 })
                    // getSelectGoodsPredects()
                  }}>
                  筛选
                </Button>
              </Space>
            </Form.Item>
          </Form>
          <Space>
            <Button
              type="primary"
              size="small"
              onClick={() => {
                getListItems().forEach((itemsedr) => {
                  if (itemsedr.chrackData.check_pass) {
                    itemsedr.selectStatus = true
                  }
                })
                setGetSelectGoodsPredects([...getSelectGoodsPredects])
              }}>
              选择【当前页】商品
            </Button>
            <Button
              type="primary"
              size="small"
              onClick={() => {
                getSelectGoodsPredects.forEach((itemsedr) => {
                  if (itemsedr.chrackData.check_pass) {
                    itemsedr.selectStatus = true
                  }
                })
                setGetSelectGoodsPredects([...getSelectGoodsPredects])
              }}>
              选择【全部】商品
            </Button>
            <Button
              type="primary"
              size="small"
              onClick={() => {
                getSelectGoodsPredects.forEach((itemsedr) => {
                  if (itemsedr.chrackData.check_pass) {
                    itemsedr.selectStatus = false
                  }
                })
                setGetSelectGoodsPredects([...getSelectGoodsPredects])
              }}>
              取消选中
            </Button>
            <Button
              type="primary"
              size="small"
              onClick={() => {
                getSelectGoodsPredects.forEach((itemsedr) => {
                  if (itemsedr.chrackData.check_pass) {
                    itemsedr.selectStatus = !itemsedr.selectStatus
                  }
                })
                setGetSelectGoodsPredects([...getSelectGoodsPredects])
              }}>
              反选
            </Button>
            <Button
              type="primary"
              size="small"
              onClick={() => {
                setShowGoodsStatus(!showGoodsTypeStatus)
              }}>
              {showGoodsTypeStatus ? "显示全部商品" : "只显示可用商品"}
            </Button>
          </Space>
          <Space
            wrap
            style={{
              width: "100%"
              // height: 700
            }}
            size={16}>
            {getListItems().map((itemsd, inter) => {
              // if (showGoodsTypeStatus && !itemsd.chrackData.check_pass) return null
              return (
                <div
                  className="styleContent"
                  key={inter}
                  onClick={() => {
                    if (!itemsd.chrackData.check_pass)
                      return message.error(itemsd.chrackData.reject_reason)
                    itemsd.selectStatus = !itemsd.selectStatus
                    setGetSelectGoodsPredects([...getSelectGoodsPredects])
                  }}>
                  <div className="topimage">
                    <ImgDefault
                      style={{ width: 160, height: 160 }}
                      imgSrc={(() => {
                        const geturls = CircularJSON.parse(CircularJSON.stringify(itemsd))
                        const imgae = geturls.img.replace("obj/", "")
                        return imgae + "~110x110_q75.image"
                      })()}
                      mask={false}
                    />
                    <div className="selecter">
                      <Checkbox
                        size="large"
                        checked={itemsd.selectStatus}></Checkbox>
                    </div>
                  </div>
                  <Space direction="vertical" size={4}>
                    <Tooltip.Auto title={itemsd.name} lineClamp={2}>
                      {itemsd.name}
                    </Tooltip.Auto>
                    <Space>
                      <Tooltip.Auto title={itemsd.product_id} lineClamp={1}>
                        <span
                          style={{
                            fontSize: 12,
                            color: "#898b8f"
                          }}>
                          DI:{itemsd.product_id}
                        </span>
                      </Tooltip.Auto>
                      <span
                        className="copy"
                        onClick={(e) => {
                          e.stopPropagation()
                          copyToClipboard(itemsd.product_id)
                        }}>
                        <Icon type="CopyIcon"></Icon>
                      </span>
                    </Space>
                    <Space
                      direction="vertical"
                      size={2}
                      style={{
                        fontSize: 12,
                        color: "#898b8f"
                      }}>
                      <Space>
                        价格：
                        {itemsd.min_price === itemsd.max_price
                          ? (itemsd.min_price / 100).toFixed(2)
                          : (itemsd.min_price / 100).toFixed(2) +
                          "-" +
                          (itemsd.max_price / 100).toFixed(2)}
                      </Space>
                      <Space>库存：{itemsd.stock_num}</Space>
                    </Space>
                    {!itemsd.chrackData.check_pass && (
                      <Tooltip.Auto
                        title={itemsd.chrackData.reject_reason}
                        lineClamp={2}>
                        <div className="errConternt">
                          {itemsd.chrackData.reject_reason}
                        </div>
                      </Tooltip.Auto>
                    )}
                  </Space>
                  {itemsd.chrackData.check_pass && (
                    <div
                      // className="botonconte selectIcons"
                      className={
                        itemsd.selectStatus
                          ? "botonconte selectIcons"
                          : "botonconte"
                      }>
                      <Space align="center">
                        {itemsd.selectStatus ? (
                          <>
                            <Icon type="CloseIcon"></Icon>取消选择
                          </>
                        ) : (
                          <>
                            <Icon type="FinishIcon"></Icon>选择
                          </>
                        )}
                      </Space>
                    </div>
                  )}
                  {!itemsd.chrackData.check_pass && (
                    <Tooltip title={itemsd.chrackData.reject_reason}>
                      <div className="norepiterbox"></div>
                    </Tooltip>
                  )}
                </div>
              )
            })}
          </Space>
        </Space>
      </Modal>
      {/* // 匹配活动配置时需要 */}
      <Modal
        visible={addActConfig}
        onCancel={() => setAddActConfig(false)}
        onOk={() => {
          if (
            addAllConfigData[addConfigActIndex] &&
            addAllConfigData[addConfigActIndex].selectActPrdlist &&
            addAllConfigData[addConfigActIndex].selectActPrdlist.length > 0
          ) {
            getPrdListSkus(addAllConfigData[addConfigActIndex].indexkey)
          }
          setAddActConfig(false)
        }}
        width={1050}
        bodyBottomMask
        wrapClassName={"add-content-modal"}
        title="添加活动配置">
        <Table
          scroll={{ y: 420 }}
          columns={selectLtaLpPrittable}
          dataSource={configDataUse}
          style={{ width: "100%", height: 470 }}
          pagination={false}
          locale={{
            emptyText: (
              <Empty
                className="empty-img-emotion"
                description={
                  <>
                    请前往(价格,库存,限购)配置添加配置
                    <Button
                      type="link"
                      onClick={() => {
                        setAddActConfig(false)
                        props.setcurrent && props.setcurrentAdd("addConfigBuy")
                      }}>
                      添加配置
                    </Button>
                  </>
                }
              />
            )
          }}
          rowKey="index"></Table>
      </Modal>
      {addUpContentStatus && (
        <div
          style={{
            background: "rgba(255, 255, 255)",
            width: "100%",
            height: "100%",
            position: "absolute",
            top: 0,
            left: 0,
            zIndex: 100,
            display: "flex",
            justifyContent: "center",
            alignItems: "center"
          }}>
          <div
            className="topContent"
            style={{
              color: "#252931",
              margin: 0,
              fontSize: 16,
              fontWeight: 500,
              padding: "16px 24px",
              position: "absolute",
              top: 0,
              left: 0,
              width: "100%",
              borderBottom: "1px solid #eeeff0"
            }}>
            {addUpActAll ? "创建完成" : "正在创建活动"}
          </div>
          <Space align="center" direction="vertical">
            {/* isUserStopStatus ? <Icon style={{ color: '#c21' }} svgProps={{ style: { width: 60, height: 60 } }} type="InfoIcon" /> : 手动停止的代码 */}
            {addUpActAll ? (
              <svg
                width="120"
                height="120"
                viewBox="0 0 120 120"
                fill="none"
                xmlns="http://www.w3.org/2000/svg">
                <g clip-path="url(#clip0_445_33713)">
                  <path
                    fill-rule="evenodd"
                    clip-rule="evenodd"
                    d="M60 93C78.2254 93 93 78.2254 93 60C93 41.7746 78.2254 27 60 27C41.7746 27 27 41.7746 27 60C27 78.2254 41.7746 93 60 93ZM77.6492 53.4642C79.1589 51.49 78.7823 48.6658 76.8081 47.1561C74.8339 45.6464 72.0097 46.023 70.5 47.9972L55.4514 66.1288L48.5523 58.7345C47.0265 56.7727 44.1992 56.4193 42.2375 57.9451C40.2757 59.471 39.9223 62.2982 41.4481 64.26L51.9295 76.26C52.786 77.3613 54.1049 78.003 55.5 77.9973C56.8951 77.9915 58.2087 77.3391 59.0562 76.2308L77.6492 53.4642Z"
                    fill="#397BFF"
                  />
                  <path
                    opacity="0.1"
                    fill-rule="evenodd"
                    clip-rule="evenodd"
                    d="M22.5 2C22.5 0.895431 21.6046 0 20.5 0H15.5C14.3954 0 13.5 0.895431 13.5 2L13.5 13.5H2C0.895431 13.5 0 14.3954 0 15.5V20.5C0 21.6046 0.895431 22.5 2 22.5H13.5L13.5 34C13.5 35.1046 14.3954 36 15.5 36H20.5C21.6046 36 22.5 35.1046 22.5 34V22.5H34C35.1046 22.5 36 21.6046 36 20.5V15.5C36 14.3954 35.1046 13.5 34 13.5H22.5V2Z"
                    fill="#397BFF"
                  />
                  <path
                    opacity="0.3"
                    fill-rule="evenodd"
                    clip-rule="evenodd"
                    d="M113.25 68C113.25 66.8954 112.355 66 111.25 66H110.75C109.645 66 108.75 66.8954 108.75 68V72.75H104C102.895 72.75 102 73.6454 102 74.75V75.25C102 76.3546 102.895 77.25 104 77.25H108.75V82C108.75 83.1046 109.645 84 110.75 84H111.25C112.355 84 113.25 83.1046 113.25 82V77.25H118C119.105 77.25 120 76.3546 120 75.25V74.75C120 73.6454 119.105 72.75 118 72.75H113.25V68Z"
                    fill="#397BFF"
                  />
                  <path
                    opacity="0.4"
                    fill-rule="evenodd"
                    clip-rule="evenodd"
                    d="M76.7734 104C76.7734 102.895 75.878 102 74.7734 102H74.2734C73.1689 102 72.2734 102.895 72.2734 104V108.75H67.5234C66.4189 108.75 65.5234 109.645 65.5234 110.75V111.25C65.5234 112.355 66.4189 113.25 67.5234 113.25H72.2734V118C72.2734 119.105 73.1689 120 74.2734 120H74.7734C75.878 120 76.7734 119.105 76.7734 118V113.25H81.5234C82.628 113.25 83.5234 112.355 83.5234 111.25V110.75C83.5234 109.645 82.628 108.75 81.5234 108.75H76.7734V104Z"
                    fill="#397BFF"
                  />
                </g>
                <defs>
                  <clipPath id="clip0_445_33713">
                    <rect width="120" height="120" fill="white" />
                  </clipPath>
                </defs>
              </svg>
            ) : (
              <Spin size="large" />
            )}
            <h2>
              {addUpActAll
                ? "创建完成"
                : "正在创建优惠券，请勿关闭或刷新浏览器，窗口"}
            </h2>
            {/* <h2>将创建以下活动</h2> */}
            {addUpActAll && (
              <Space direction="vertical">
                <h3
                  style={{
                    textAlign: "center"
                  }}>
                  共创建{upItemAddStatusState.length}个活动
                </h3>
                {!!upItemAddStatusState.filter((item) => {
                  return item.status === 2
                }).length && (
                    <Space>
                      <Tag type="success">成功</Tag>{" "}
                      {
                        upItemAddStatusState.filter((item) => {
                          return item.status === 2
                        }).length
                      }
                      个活动，包含{" "}
                      {(() => {
                        let asq = 0
                        upItemAddStatusState
                          .filter((item) => {
                            return item.status === 2
                          })
                          .forEach((res) => {
                            asq += res.data.promotion_goods.length
                          })
                        return asq
                      })()}
                      个商品{" "}
                      {(() => {
                        let asq = 0
                        upItemAddStatusState
                          .filter((item) => {
                            return item.status === 2
                          })
                          .forEach((res) => {
                            res.data.promotion_goods.forEach((skul) => {
                              asq += skul.promotion_skus.length
                            })
                          })
                        return asq
                      })()}
                      个SKU
                    </Space>
                  )}
                {!!upItemAddStatusState.filter((item) => {
                  return item.status === 3
                }).length && (
                    <Space>
                      <Tag type="error">失败</Tag>{" "}
                      {
                        upItemAddStatusState.filter((item) => {
                          return item.status === 3
                        }).length
                      }
                      个活动，包含{" "}
                      {(() => {
                        let asq = 0
                        upItemAddStatusState
                          .filter((item) => {
                            return item.status === 3
                          })
                          .forEach((res) => {
                            asq += res.data.promotion_goods.length
                          })
                        return asq
                      })()}
                      个商品{" "}
                      {(() => {
                        let asq = 0
                        upItemAddStatusState
                          .filter((item) => {
                            return item.status === 3
                          })
                          .forEach((res) => {
                            res.data.promotion_goods.forEach((skul) => {
                              asq += skul.promotion_skus.length
                            })
                          })
                        return asq
                      })()}
                      个SKU 请联系客服反馈问题
                    </Space>
                  )}
              </Space>
            )}

            <Table
              style={{
                width: "90%",
                margin: "auto"
              }}
              columns={addUpActDataTabs}
              dataSource={upItemAddStatusState}
              pagination={false}
              rowKey="indexkey"
              scroll={{ y: 400 }}></Table>
            {addUpActAll && (
              <Space
                style={{
                  marginTop: 30
                }}>
                <Button
                  size="mini"
                  type="primary"
                  onClick={() => {
                    setAddUpContentStatus(false)
                  }}>
                  返回继续创建
                </Button>
              </Space>
            )}
          </Space>
        </div>
      )}
    </div>
  )
}

export default forwardRef(AddLtaLp)
